How to Create Channel Definition Format (CDF) Files
Channel Definition Format (CDF) files give Web authors another way to organize their sites. The hierarchical structure of CDF files makes it easy to offer users a meaningful subset of a site's contents.
Microsoft Active Channel technology, which is supported by Microsoft Internet Explorer 4.0 or later, is one implementation of CDF files. Smart offline Favorites, which are supported by Microsoft Internet Explorer 5 or later, are another implementation of CDF files. A smart offline Favorite is a Web page that specifies a subset of additional content to be cached when the page is selected as an offline Favorite. The additional content to be cached is defined in a CDF file.
Smart offline Favorites, like channels, enable users to view Web pages from the cache. Cached content is easier for users to find, and the pages can be viewed independent of a Web connection.
Active Channel sites can employ all of the CDF elements. Unlike channels, however, the smart offline Favorites feature in Internet Explorer 5 and later uses a subset of the CDF vocabulary, ignoring the CDF elements it doesn't use. Smart offline Favorites, for example, don't employ the SCHEDULE element, which provides an author-defined schedule for updating, or "synchronizing" content.
It is not necessary to author separate CDF files to fulfill different roles. One CDF file, for example, can be used for channels and offline Favorites. This article demonstrates how easy it is to create a single, "generic" CDF file to take advantage of CDF support.
- Implementation Steps
- Link Your Web Page to the CDF File
- Related topics
Support for CDF files began with Internet Explorer 4.0. Earlier versions of Windows Internet Explorer don't recognize CDF files. This tutorial includes a script you can copy and paste to your Web pages to check the user's browser version, enabling you to prevent undesirable results.
Support for smart offline Favorites began with Internet Explorer 5. The "Offline" value for the REL attribute of the LINK element is supported by Internet Explorer 5 and later. This value is key to the implementation of smart offline Favorites. Earlier versions of Internet Explorer ignore LINK REL="Offline".
You can create a CDF file with any text editor.
The only other thing you'll need is a Web site. Any Web site will work; even a single Web page will do. Basic HTML knowledge is helpful here, but you don't need to be an expert to implement this technology.
In this section, you'll learn, step-by-step, how easy it is to author a generic CDF file. You'll create the CDF file first and then link a page on your Web site to the CDF file.
Follow these steps to create a CDF file:
- Identify the XML character set and version number on the first line of a new, blank text file.
The XML processing instruction indicates an XML document. For readability, it's a good idea to specify the character set and version numbers even when default values are assigned, as in the following example:
<?XML ENCODING="UTF-8" VERSION="1.0"?>
- Start and end the CDF file with the CHANNEL element.
Everything you add to the CDF file will be placed between the beginning and ending CHANNEL tags. In the following example, the CHANNEL element defines the top level of the CDF file's hierarchy. Its CHANNEL attribute points to the top-level Web page in the CDF file. The other attributes of the example CHANNEL element specify the date the page was last modified, and the number of levels deep the browser should site crawl and precache the content of the CHANNEL.Note CDF supports only HTTP, Secure Hypertext Transfer Protocol (HTTPS), and File Transfer Protocol (FTP) protocols. If a different protocol is used, Internet Explorer will fail to navigate to the page without notifying the user.
<CHANNEL HREF="http://domain/folder/pageOne.extension" LASTMOD="1998-11-05T22:12" PRECACHE="YES" LEVEL="1"> . . . </CHANNEL>
In the preceding example, Internet Explorer is instructed to cache pageOne and all the pages linked to it. This is all you really need in a "no frills" CDF file where pageOne represents the Web site's entry page, and all the pages linked to pageOne should be cached for offline use.
If it isn't appropriate to cache all the pages linked to pageOne, set the value of the CHANNEL element's CHANNEL attribute to 0. You'll learn how to cache individual pages in Step 6.Note If you include the CHANNEL attribute in the top-level CHANNEL element, you'll be able to use relative URLs in all of its child elements.
- Nest TITLE and ABSTRACT elements within the CHANNEL element.
The text strings within these elements will represent your channel in the Windows Media Showcase on your users' desktops and also in the Channel bar in Internet Explorer 4.0, or the Favorites bar in Internet Explorer 5 and later. The title appearing in the head section of your Web page will represent offline Favorites on the Favorites bar in Internet Explorer 5 and later. The TITLE and ABSTRACT elements are ignored by the offline Favorites feature in Internet Explorer 5 and later.
<TITLE>Title of your Channel</TITLE> <ABSTRACT>Synopsis of your channel's contents.</ABSTRACT>
- Create an update SCHEDULE.
Smart offline Favorites in Internet Explorer 5 will not use the update schedule you create in your CDF file. Like TITLE and ABSTRACT, the SCHEDULE element is ignored by the smart offline Favorites feature in Internet Explorer 5 and later. The SCHEDULE element does work with channels. Users can choose to automatically update a Favorite's content daily, weekly, monthly, or when they choose Synchronize from the Tools menu.
In the following example, the content will be synchronized every two weeks:
<SCHEDULE> <INTERVALTIME DAY="14"/> </SCHEDULE>
- Add optional LOGO images.
The images you specify will represent your channel in the Windows Media Showcase on your users' desktops and also in the Channel bar in Internet Explorer 4.0, or the Favorites bar in Internet Explorer 5 and later. Default images will be provided for you wherever necessary.
<LOGO HREF="http://domain/folder/wideChannelLogo.gif" STYLE="IMAGE-WIDE"/> <LOGO HREF="http://domain/folder/imageChannelLogo.gif" STYLE="IMAGE"/> <LOGO HREF="http://domain/folder/iconChannelLogo.gif" STYLE="ICON"/>
Additional information on logo design guidelines can be found in Creating Active Channel Logo Images.
- Specify individual pages with the ITEM element, if desired.
The Web pages you specify will constitute the "intelligent subset" of your content that enhances your users' browsing experience. With Internet Explorer 5 and later, authors have the ability to choose which pages are cached when users add pages to Favorites. Previously, browsers only gave users the option of caching all of a page's links, or none of them. Now you can offer your users a more meaningful alternative.
By setting the values of the ITEM attribute to Yes, and the ITEM attribute to 1, pageTwo will be cached in the following example, as will all of the pages linked to pageTwo. Note that TITLE, ABSTRACT and LOGO elements can be nested inside the ITEM element to represent the page on the Windows Media Showcase and also in the Channel bar in Internet Explorer 4.0, or the Favorites bar in Internet Explorer 5 and later.
<ITEM HREF="http://domain/folder/pageTwo.extension" LASTMOD="1998-11-05T22:12" PRECACHE="YES" LEVEL="1"> <TITLE>Page Two's Title</TITLE> <ABSTRACT>Synopsis of Page Two's contents.</ABSTRACT> <LOGO HREF="http://domain/folder/pageTwoLogo.gif" STYLE="IMAGE"/> <LOGO HREF="http://domain/folder/pageTwoLogo.gif" STYLE="ICON"/> </ITEM>
- Save the text file with a .cdf extension.
Without this extension, Internet Explorer will not perform the expected actions for CDF files. For example, the CDF file might display as text in the browser window rather than launching the Add Channel dialog box. This step ensures that the server will return the correct MIME type to the browser.
Here's a generic CDF file that includes each of the elements outlined above.
<?XML ENCODING="UTF-8" VERSION="1.0"?> <CHANNEL HREF="http://domain/folder/pageOne.extension" BASE="http://domain/folder/" LASTMOD="1998-11-05T22:12" PRECACHE="YES" LEVEL="0"> <TITLE>Title of your Channel</TITLE> <ABSTRACT>Synopsis of your channel's contents.</ABSTRACT> <SCHEDULE> <INTERVALTIME DAY="14"/> </SCHEDULE> <LOGO HREF="wideChannelLogo.gif" STYLE="IMAGE-WIDE"/> <LOGO HREF="imageChannelLogo.gif" STYLE="IMAGE"/> <LOGO HREF="iconChannelLogo.gif" STYLE="ICON"/> <ITEM HREF="pageTwo.extension" LASTMOD="1998-11-05T22:12" PRECACHE="YES" LEVEL="1"> <TITLE>Page Two's Title</TITLE> <ABSTRACT>Synopsis of Page Two's contents.</ABSTRACT> <LOGO HREF="pageTwoLogo.gif" STYLE="IMAGE"/> <LOGO HREF="pageTwoLogo.gif" STYLE="ICON"/> </ITEM> </CHANNEL>
There are two ways to link your Web page to the CDF file. The way you choose will depend on whether you are creating a channel or an offline Favorite. If you want your CDF file to fulfill both of these roles, follow the steps in both of the following sections.
- Copy this image button to your Web server.
Note To use the Microsoft Add Active Channel button logo image, you must sign up and accept the terms of the Active Channel Logo Agreement.
- Copy and paste the following script between the beginning and ending head tags on your Web page.
- Copy and paste the following script between the beginning and ending BODY tags on your Web page.
This script is used to place the image button on your Web page, allowing users to install your channel.
Edit the above script as follows:
- Replace each occurrence of uniqueName with a unique name for each logo placed on the page.
- Include the actual URL of the image button on your server in place of urlOfImageButton.
- Include the actual CDF of the CDF file on your server in place of urlToCDF.
Add the following HTML between the beginning and ending HEAD tags in your Web page. LINK is an HTML element that specifies a relationship with another object. REL is an attribute of LINK that sets or retrieves the specified relationship. For offline Favorites, the value of the REL attribute is "Offline."
<LINK REL="Offline" HREF="http://domain/folder/file.cdf">
- Introduction to Active Channel Technology
- CDF Reference
- Designing Active Channel Sites
- Developing an Active Channel Site
- Enhancing Offline Favorites
- Creating Active Channel Logo Images