1. Trang chủ
  2. » Công Nghệ Thông Tin

XML in 60 Minutes a Day phần 9 docx

72 203 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 72
Dung lượng 9,2 MB

Nội dung

intervene, cancel, or otherwise modify the nature of the information to be delivered or the delivery schedule. CDF differs from most XML-related languages in two major ways: ■■ There is no universal DTD for it, so its documents need only be well formed and not necessarily valid. However, individual Web publishers can create their own validity documents to test against for validity. ■■ The CDF specification is presently (only) a W3C Note, with no realistic prospect of ever becoming a W3C Recommendation. Nevertheless, Microsoft continues to develop and refine CDF, just as it continues to develop successive versions of IE. Additionally, CDF enables automatic user notification when Web site con- tent changes. It has what are called “other data operations” too: the ability to search, index, profile, filter, and personalize content. When downloaded to an end user’s browser, CDF channels resemble local links to and indexes of remote resources. They are links that, if you are online (in other words, if you are connected to the Web), can take you directly to the Web site source. If you are not online but are using the offline browser options, you can configure your channels to display their content whenever you want to, even if you are not connected to the Web, as long as your system was given an opportunity to go on online and download the information to your hard disk. The Publisher’s Side of CDF: Creating CDF Channels So far, we have examined channels from a user’s standpoint. Now let’s exam- ine CDF from the Web publisher’s side to see how channels are created and added to Web sites. We stated earlier that a channel is a collection of information, commonly considered to be specific Web pages within one Web site. We can put the spec- ifications for any single channel in one CDF document, which is an XML- related document, or we can create hierarchies of channels and subchannels within one CDF document. In fact, you may have noticed that in your list of example (surviving) Web sites that provide the opportunity to create channels by using the Add Active Channel buttons, the CDF files are often the files that appear in the Web site URL. The CDF document is separate from other Web pages but is usually linked to one of the Web pages. The CDF files also provide means for Web publishers to specify Web page document titles, URLs, content, description, browser and desktop icons, user traffic logging, the creation of a schedule for updating and synchronization, and 546 Chapter 14 422541 Ch14.qxd 6/19/03 10:13 AM Page 546 additional functionality. They also provide the capability for end users to sub- scribe to a channel, as well as other features, such as authentication and other personalization features, that are beyond the introductory level of this book. If you intend to create channels, here is the general strategy: 1. Design the channel. 2. If you will be using customized logo images instead of the default images, you have to create the logo images first. 3. Create the actual CDF file, reflecting your design. 4. Post the CDF file so that it will be publicly accessible when end users choose to subscribe to the corresponding channel. 5. Create some means to make the channel available for subscription by the user community. In the next few sections, we discuss the steps in more detail. Designing the Channel Our first and arguably most important step is determining the structure of the channel(s) and the hierarchy of subchannels, items, and other functions within it. The design could, but doesn’t have to, reflect the structure of an existing Web site. The design may even consist of just a sample of the Web site’s con- tent and can also have a different hierarchy. Figure 14.8 illustrates the relation- ship between a Web site, a channel definition document, and the view that appears in the browser of an end user who subscribes to the channel. The Web site structure is indicated in the diagram at the top. (The connect- ing lines indicate various hyperlinks among the documents.) The correspond- ing channel definition document, named gems.cdf, is shown on the lower left. Its top-level channel calls for one document—in this case, the home page document—and its seven subchannels call for various pages located at various link levels in the Web site. The documents referenced in the gems.cdf channel definition document are shaded for illustration. Notice that, after the relevant documents have been specified in the CDF file, other documents that are not referenced remain in the Web site. They are displayed when you surf to the Web site online but do not form part of the channel definition. So they will not appear if you download the channel and examine it offline. On the bottom right side of the figure is a depiction of a browser window belonging to an end user who has subscribed to the channel. In the browser’s Favorites bar, on the left of the window, you can see how the channel and the items are referenced. CDF 547 422541 Ch14.qxd 6/19/03 10:13 AM Page 547 Figure 14.8 Simplified channel development schematic. The structure of the channel is created in the CDF file using one or more <channel> elements that represent the major segments—that is, the top-level channel and other subchannels, if you choose to use subchannels—and usu- ally more <item> elements. All these components form the hierarchy within the <channel>. When designing channels, observe the following best practices: 1st link level 2nd link level 3rd link level 4th link level Home page Web Site Structure gems.cdf Channel Definition Document 548 Chapter 14 422541 Ch14.qxd 6/19/03 10:13 AM Page 548 ■■ Microsoft recommends that a channel should have no more than eight total subitems in the first level. We agree. If you follow these sugges- tions, you prevent subscribers from being overwhelmed with informa- tion and images, provide a uniform look and feel among your channels, and conserve bandwidth while minimizing download delays. ■■ You should create and use your own unique logo images with channels and items. Early versions of IE didn’t provide any default logos, but later versions do. But the default logos should be replaced by logos more appropriate to your Web site and channels. ■■ Consider inserting a <schedule> element in the file, so that as the Web site owner, you maintain control over updates and synchronization. Creating Logo Images Web publishers should create and use appropriate images for their channel and item logos. However, Internet Explorer 4.0 and later provides default images wherever necessary. You can place various types and sizes of logo images in several locations in a channel’s user interface, for example, in the Favorites bar in the browser, in the Favorites menu, and on the Active Desktop. To do so, we recommend observing Microsoft’s logo dimension and other requirements. These require- ments are listed in the discussion of the <logo> element, later in this chapter. The Logical Structure of a CDF Document After we design our channel and create logo images, we can create the channel definition document, which we’ll also refer to as the CDF document or CDF file. Because CDF is an XML-related application, it is important to remember that the CDF document must observe XML’s stringent vocabulary and struc- tural rules as discussed throughout the earlier chapters of this book. CDF files contain a prolog and a root element called <channel>. The other elements that make up the CDF file are nested within the top-level <channel> element. We discuss the logical structure requirements in the next few sections. The Prolog It is mandatory to include a prolog in a CDF document. The prolog could be as simple as a one-line XML declaration, or it could contain the XML declaration, a document type declaration, and one or more comments. A document type declaration, if included, contains a reference to an XML DTD that you develop on your own. There is no official publicly posted DTD CDF 549 422541 Ch14.qxd 6/19/03 10:13 AM Page 549 or schema for CDF, as there is for other XML-related languages. Therefore, integrated development environment applications and other editors are not likely to be able to validate CDF files automatically without having been pro- vided with DOCTYPE declarations and URIs that point to those validation documents. If you intend to create your own validation documents, you can get a head start by examining the declarations for the early-version CDF elements and attributes in the original specification submission to the W3C at www .w3.org/TR/NOTE-CDFsubmit.html. You can adopt or adapt those declara- tions into your own DTD (or schema, if you want to do the converting) file and add declarations for your unique custom elements or attributes. The <channel> Element The <channel> element performs two functions: ■■ A <channel> element is used as the top-level (or root) element. ■■ Each channel or subchannel definition must be contained within its own <channel> element. In other words, the full definition of the chan- nel (its title, description, schedule information, and other associated items) must fall between the corresponding <channel> tags. A CDF document can contain one or more channel definitions. If it contains more than one channel definition, each must be enclosed within its own <channel> element. Channels can thus be nested within other channels. The child channels are called subchannels and are subordinate to the parent chan- nel in which they are nested. The top-level <channel> element in a document has no parent element, but subchannel <channel> elements have a <channel> element as a parent. Table 14.1 lists the attributes we can use with the <channel> element. Remember that all attribute values must be enclosed in quotation marks, even if the value is a number. If we use more than one mechanism (for example, BASE and HREF) to spec- ify a URL for a channel and the URLs contradict one another, IE applies the fol- lowing precedence: 1. The HREF attribute found in the start tag of the <channel> element. 2. The HREF attribute specified in the start tag of an <A> (anchor) ele- ment that has been inserted as an immediate child of the <channel> element, if one has been inserted. Thus, CDF document developers must be aware of their options. They must be precise in the selection of the location of the HREF attribute. If we want one to appear in an <A> element, the HREF specification should not appear in any parent <channel> element of the <A> element. 550 Chapter 14 422541 Ch14.qxd 6/19/03 10:13 AM Page 550 Table 14.1 <Channel> Element Attributes ATTRIBUTE NAME EXPLANATION BASE Optional. Specifies the base URL for the channel and is used to resolve the relative URLs specified in <item> and <channel> elements contained within the same channel or subchannel. Inheritance is downward only, not across to other sibling subchannels nor upward. BASE attributes in a subchannel supersede those in parent channels from that point downward. When specifying, ensure that it ends with a trailing / to avoid confused pathing. HREF Optional. Value is also a URL. Specifies which Web page will be displayed in the browser when the channel is selected. Optional because the same URL could also be specified in a child <A> element. If a BASE attribute specification has been specified in a parent element, BASE is inherited, and then the HREF only has to be a relative path. If no BASE has been specified, the HREF URL must be an absolute address. LASTMOD Optional. Provides the date and time, in terms of Greenwich Mean Time, when the page referenced by the HREF attribute was last modified. Allows the channel’s end user to determine whether the content has changed since the last download. Updates are downloaded only if the date associated with the cached information is older than the LASTMOD value in the CDF file. The date format is yyyy-mm- ddThh:mm. The capital T must appear between the date and the time. LEVEL Optional. Specifies the number of levels (or links, if you prefer) deep that the client should site crawl and precaches the Web page content from the URL specified in the HREF attribute. Default is 0 (zero), meaning that the end user can only precache the data found at the URL specified in the <channel>, along with any images it uses. If the URL page contains frames, all content inside the frames is retrieved. The maximum number is three. Remember the structure of the target Web site. If there are many links, even low numbers can create excessive traffic and long download times. PRECACHE Optional. Specifies whether content is downloaded. Values: No (content will not be downloaded into the cache; value of the LEVEL attribute is subsequently ignored); Yes (default value; content will be downloaded only if the user has specified that it should be); Default (whatever the end user has specified is acceptable). SELF Optional. Added to the top-level channel, to indicate the location of the CDF file used for creating a channel subscription. This attribute is unnecessary and is deprecated. Only supported by newer versions for backward compatibility. CDF 551 422541 Ch14.qxd 6/19/03 10:13 AM Page 551 Other CDF Elements There are two basic varieties of child elements within <channel> elements: ■■ Those that can occur only once per <channel> element. Examples: <A>, <abstract>, <log>, <login>, <logo>, <logtarget>, <schedule>, and <title>. ■■ Those that can occur one or more times. Examples: <channel>, <item>, and <softpkg>. Figure 14.9 illustrates the hierarchical structure and syntax for a sample CDF document. This CDF document contains one top-level channel that contains three sub- channels. The third subchannel contains three <item> elements. Figure 14.10 demonstrates what we see in the Favorites bar inside an IE browser window if we created a channel structured similar to the document in Figure 14.9. Figure 14.9 A simplified CDF document. <?xml version="1.0"?> <!DOCTYPE Channel SYSTEM "http://www.SpaceGems.com/dtds/cdf_sample.dtd" > <! Comment - Example CDF Document - -> <channel> <logo HREF=" " STYLE=" " /> <schedule STARTDATE=" > <intervaltime /> <earliesttime /> <latesttime /> </schedule> <channel HREF=" " BASE=" " > <title> </title> <abstract> </abstract> <logo HREF=" " STYLE=" " /> </channel> <channel HREF=" " BASE=" " > <title> </title> <abstract> </abstract> <logo HREF=" " STYLE=" " /> </channel> <channel HREF=" " BASE=" " > <title> </title> <abstract> </abstract> <logo HREF=" " STYLE=" " /> <item HREF=" " > <logo HREF=" " STYLE=" " /> <title> </title> <abstract> </abstract> </item> <item HREF=" " > <logo HREF=" " STYLE=" " /> <title> </title> <abstract> </abstract> </item> <item HREF=" " > <logo HREF=" " STYLE=" " /> <title> </title> <abstract> </abstract> </item> </channel> </channel> Subchannel Subchannel Top-Level Channel Subchannel Item Item Item 552 Chapter 14 422541 Ch14.qxd 6/19/03 10:13 AM Page 552 Figure 14.10 Favorites bar version of channel defined in previous CDF file. From Figure 14.10, we would presume that the top-level channel is called Space Gems Home Page. The three subchannels would be called Space Gems Diamonds, Space Gems Emeralds, and Other Space Gems. The three items that would be displayed if you clicked the Other Space Gems subchannel, as apparently someone has done in Figure 14.10, are called Secretariat (Ruby), Ben Hur (Sapphire), and Canina (Rose Quartz). Now we’ll discuss the other elements and attributes that are valuable to the creation of CDF files. Depending on your ultimate intentions for your chan- nels and the associated CDF files, you will include some and exclude others. Some CDF files, for example, may be intended for Microsoft-related webcast- ing, such as Active Desktop channels or software update channels, which we will not discuss in this introductory-level chapter. The elements you use depend on the values you specify for the <usage> element. <A> The <A> element defines a hyperlink. Its only attribute is the mandatory HREF, whose value is the URL to be associated with the parent element, which can be Items Subchannels Top-Level Channel CDF 553 422541 Ch14.qxd 6/19/03 10:13 AM Page 553 a <channel> or <item> element. <A> has no child elements. We discuss other <A> element implications in the section pertaining to the <item> element. The <A> element is also important to the Web page document that contains the CDF file. In the <body> element of the Web page document, the CDF file is specified as the value of an HREF attribute in the document’s <A> element. <abstract> When a mouse pointer pauses over a <channel> or <item> title, Internet Explorer displays the content specified within the <abstract> element in the respective <channel> element. On-screen, in the browser window, the content appears in a shaded box called a ToolTip (some call it a ScreenTip) that appears briefly and then disappears. Figure 14.11 shows us an example of a ToolTip that appears as the mouse pointer hovers over the Space Gems Main Informa- tion Channel in the Favorites bar. The <abstract> element can be used as a child element of the <channel>, <implementation>, <item>, and <softpkg> elements. <abstract> has no child elements of its own. At one time, <abstract> was an attribute of <channel>, but it became its own element with CDF Version 0.4. The only attribute for <abstract> is the optional XML-SPACE, whose value specifies how white space is to be treated in the ToolTip. Possible values for XML-SPACE are Default, which permits white space to be filtered out during file processing, and Preserve, which ensures all white-space characters are retained. Figure 14.11 ToolTip example. 554 Chapter 14 422541 Ch14.qxd 6/19/03 10:13 AM Page 554 <schedule> The <schedule> element, with the help of other related elements, allows us to define an update/synchronization schedule—that is, how often, and during what time period, the channel should be updated. The parent element of <schedule> is <channel>. Child elements of <schedule> are <start>, <end>, <intervaltime>, <earliesttime>, and <latesttime>. <schedule> has three optional attributes: STARTDATE. The date on which the schedule is to take effect; specified in yyyy-mm-dd. STOPDATE. The date on which the schedule is no longer in effect; also specified in yyyy-mm-dd. TIMEZONE. Values are expressed as +/- zzzz, where the z’s specify a time offset from GMT in hhmm. The plus or minus signs indicate whether the time specified is ahead (+) or behind (-) GMT. Values for TIMEZONE impact the child elements <earliesttime> and <latesttime>. <intervaltime> <intervaltime> specifies the length of time between channel updates. Its par- ent element is <schedule> and it has no child elements, although it is com- monly coordinated with the sibling elements <earliesttime> and <latesttime>. Its attributes are all optional: DAY. The value is a nonzero number specifying the days between updates. HOUR. Value is a nonzero number based on a 24-hour clock, specifying the number of hours, in addition to the value of DAY, that you have to wait before updating is allowed. MIN. Value is a nonzero number specifying additional minutes that you have to wait before updating is allowed. As indicated by the attributes and their values, the interval effects of the attributes are additive. Here is an example that specifies that the interval between updates will be 7 days, 12 hours, and 15 minutes: <INTERVALTIME DAY=“7” HOUR=“12” MIN=“15” /> <earliesttime> The <earliesttime> element specifies the beginning of a valid range of time within which channel updates are allowed. Its parent element is also <schedule>, and it has no child elements. Its attributes are optional and include the following: CDF 555 422541 Ch14.qxd 6/19/03 10:13 AM Page 555 [...]... process CDF Then the actual authentication input information is checked against a separate third-party authentication, authorization, and accounting application Special Characters and Character Encoding Although we’ve also discussed this topic in previous chapters, for example, in Chapter 3, “Anatomy of an XML Document,” it is worth mentioning again here When inserting data content in an element, you must... In the Schedule box, enter today’s date in the Start Date and at least five days from the current date inside the End Date Click Interval Time and enter Day= 1, Hour=1 and Min=2 g Click Earliest Time and enter Day= 1, Hour=0 and Min=2 h Click Latest Time and leave 12 as the default (that is, Day and Min should remain blank while Hour=12) Click Next i Uncheck the Log Target box Click Next j Several lines... Chapter 14 DAY The value is a nonzero number specifying the day within the specified that updates are allowed HOUR The value is a nonzero number, based on the 24-hour clock, specifying the first hour within the that updates can take place MIN The value is a nonzero number specifying the first minute within the that updates can take place ... the sidebar to validate that the links work Lab 14.4: Making the Channel Available and Verifying that It Works There are two basic ways to make a channel available One is to make the main or primary link the CDF file itself so that it is automatically invoked The second method is to place a Microsoft channel marker on the page so users can voluntarily add the channel The following code snippet supports... project is a pan-industry project undertaken by platform providers, software developers, and business leaders to create a global, open approach to service provision computing This approach allows participants to discover one another, to define their lines of business, to indicate how they will interact over the Internet (their applications, platforms, and policies), and to share information in a global registry... introductory-level material However, if you want more information, consult the CDF Resources section earlier in this chapter If you want to prevent an item from appearing in a Favorites bar—for example, when you just want the item to be downloaded and used as a link from some other page in the channel—include a element as a child element of the element, and then insert a VALUE=”none” attribute in the... on a periodic or regular basis They create CDF documents that manipulate, combine, or condense their information Then they deliver that information upon request, or preferably, on a regular schedule, and affiliate those documents with Web page documents ■ ■ Microsoft introduced CDF in 199 7 to overcome the existing shortcomings of webcasting by introducing managed webcasting In the same year, CDF and... proposals—OSD and DRP— were submitted to the W3C All the proposals were given W3C Note status W3C metadata activity was initiated to develop a standard that created a common ground RDF was developed and approved as a Recommendation in 199 9 RDF, thus, surpassed its forebears Microsoft, however, continued to develop CDF ■ ■ A Web site publisher uses certain CDF specialized elements and attributes to define... push and pull aspects, including scheduling capability, channels are not the same as favorites or bookmarks ■ ■ In this chapter, you learned three ways to investigate available channels, two ways to subscribe to channels, one method for synchronization, and one method for viewing channels offline ■ ■ The general strategy for creating channels is to design the channel, create logo images, create the CDF... public interfaces and bindings are defined and described using XML Its definition can be discovered by other software systems These systems may then interact with the Web service in a manner prescribed by its definition, using XML- based messages conveyed by Internet protocols.” The UDDI.org defines Web services as “self-contained, modular business applications that have open, Internet-oriented, standards-based . Chapter 14 422541 Ch14.qxd 6/ 19/ 03 10:13 AM Page 562 Then the actual authentication input information is checked against a separate third-party authentication, authorization, and accounting application. Special. allowed. MIN. Value is a nonzero number specifying additional minutes that you have to wait before updating is allowed. As indicated by the attributes and their values, the interval effects of the attributes. Prolog It is mandatory to include a prolog in a CDF document. The prolog could be as simple as a one-line XML declaration, or it could contain the XML declaration, a document type declaration, and one

Ngày đăng: 14/08/2014, 12:20