Chapter 18. Resource Description Framework and Channel Definition Format

CONTENTS

Chapter 18. Resource Description Framework and Channel Definition Format

  •  RDF Overview
  •  RDF Syntax
  •  The Dublin Core
  •  Using XML in Property Elements
  •  Using Abbreviated RDF Syntax
  •  RDF Containers
  •  Creating RDF Schemas
  •  CDF Overview
  •  CDF Syntax
  •  Creating a CDF File
  •  Setting a Channel Base URI
  •  Setting Last Modified Dates
  •  Setting Channel Usage

This chapter is about two XML applications that work with metadata. Metadata is data that describes data, and the applications I'm going to take a look at are Resource Description Framework (RDF) and Channel Definition Format (CDF).

As you can gather from its name, RDF is a language that lets you describe resources. Although it's typically used to describe Web documents and sites, you can also use it to describe CD collections, books in a library, a collection of antique pen knives, and more. It's a general-purpose XML application that is helping to standardize the way people handle data on the Internet. Some consistent way of working with vast amounts of data on the Internet is sorely needed, and RDF is one possible solution. You may recall our discussion of canonical XML, which puts XML documents into a format that may easily be compared RDF is actually stored in documents separate from the resources it describes, and it provides a standard description language.

CDF is similar, but more targeted. It's a language supported by only Internet Explorer, and it's designed to let you create channels in that browser to provide easy access to Web documents and sites to users. Creating a channel means letting Internet Explorer know all about what documents you want the user to be able to access and when even providing for scheduled automatic download of entire Web sites or software updates. Using channels, the user needs only to click an icon to download the documents referenced by the CDF that created the channel.

I'll start with RDF, taking a look at that XML application in overview.

RDF Overview

As mentioned, RDF is a language for describing resources. Although you can use it to describe any kind of resource, it's usually used to describe Web documents and sites. RDF is a W3C recommendation, and its main page is at http://www.w3.org/RDF. You can find the RDF model and syntax specification at http://www.w3.org/TR/REC-rdf-syntax, and the RDF schema specification at http://www.w3.org/TR/rdf-schema. Here's what the W3C says about RDF:

The Resource Description Framework (RDF) is a foundation for processing metadata; it provides interoperability between applications that exchange machine-understandable information on the Web. RDF uses XML to exchange descriptions of Web resources, but the resources being described can be of any type, including XML and non-XML resources.

What does RDF look like? Here's an example:

<?xml version="1.0" ?> <rdf:RDF     xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">     <rdf:Description about="http://www.starpowder.com/planets.html">         <Creator>Nicolas Copernicus</Creator>     </rdf:Description>

This RDF document describes the document at "http://www.starpowder.com/planets.html" and lists that document's creator, Nicolas Copernicus. RDF is general enough to support all kinds of resource descriptions, but complete generality may not be what you need to be useful, descriptions should use agreed-upon terms. Several sublanguages or grammars use RDF and define specific XML elements for describing resources. In this chapter, I'll take a look at the most popular such sublanguage, the Dublin Core. For example, RDF itself does not define an element named <Creator> to indicate the resource's creator; however, <Creator> is an element in the Dublin Core, which means that Web search engines that support the Dublin Core will know enough to search for <Creator> elements when they want to find a particular Web resource's author.

Support for RDF is growing. Here's a partial list of what's available in RDF today:

  • http://www710.univ-lyon1.fr/~champin/rdf-tutorial. An RDF tutorial online. (It's in English, even though the Web page is in France.)

  • http://www.pro-solutions.com/rdfdemo. A terrific online RDF parser. All you have to do is paste the RDF you want parsed into a box and then click the Send the RTF button. This program will tell you how an RDF parser will unpack the information in the RDF you tested.

  • http://www.w3.org/1999/02/26-modules. The PerlXmlParser, which is a set of Comprehensive Perl Archive Network (CPAN) modules by Eric Prud'Hommeaux (a W3C member), supports an RDF SAX parser and a simple database interface for Perl.

  • http://www.ics.forth.gr/proj/isst/RDF. This validating RDF parser by ICS-FORTH is a Java parser with some support for RDF schemas.

  • http://www.megginson.com/DATAX. David Megginson's DATAX (Data Exchange in XML) and http://www.megginson.com/Software is his RDF Filter. Both of these are Java tools for parsing and filtering RDF.

  • http://nestroy.wi-inf.uni-essen.de/xwmf. The Extensible Web Modeling Framework (XWMF) offers a number of tools, including an RDF parser.

  • http://www.w3.org/Library/src/HTRDF. This is John Punin's RDF parser in C.

  • http://www.mozilla.org/rdf/doc. This site explains about Mozilla's RDF implementation. I'll say more about this later in the chapter.

  • http://www.w3.org/RDF/Implementations/SiRPAC. SiRPAC, a Simple RDF Parser and Compiler, was written by Janne Saarela, of W3C.

  • http://www.pro-solutions.com/download. This is the Perl RDF::Parser module, written by Pro Solutions, Ltd. There's also an online demo available.

  • http://lists.w3.org/Archives/Public/www-rdf-interest/2000May/0009.html. This is an RDF parser in XSLT, by Dan Connolly.

One of the most useful of these resources is the Pro Solutions online RDF parser, which you can see in Figure 18.1. All you have to do to is paste the RDF that you want to parse into the parser and click the Send the RTF button. You can see one of the built-in examples supported by this parser, which uses the Dublin Core, in Figure 18.1.

The results of parsing the RDF document appear in Figure 18.2, where the document has been broken up into subjects, predicates, and objects. I'll cover what those terms mean when we get to the RDF syntax.

Figure 18.1. The online Pro Solutions RDF parser.

graphics/18fig01.gif

Figure 18.2. The results of parsing an RDF document.

graphics/18fig02.gif

Although no major browser has yet supported RDF in a big way, Mozilla, Netscape's open source version, has a lot of RDF support built into it. Here are some of the documents covering RDF in Mozilla:

  • http://www.mozilla.org/rdf/50-words.html. One of Mozilla's "In Fifty Words Or Less" articles. This is an overview of RDF and how it fits with Mozilla. It also includes examples.

  • http://www.mozilla.org/rdf/back-end-architecture.html. A very detailed document that describes how the RDF "back end" works in Mozilla. Although it doesn't have sample code now, it will one day, showing how to use the back end directly as a client and showing how to write your own RDF data source.

  • http://www.mozilla.org/rdf/doc/faq.html. The RDF-in-Mozilla FAQ. It also has some sample code.

  • http://www.mozilla.org/rdf/doc/datasource-howto.html. A cookbook approach to creating an RDF datasource.

  • http://www.mozilla.org/rdf/rdf-nglayout.html. Description of how RDF is handled in Mozilla to create a content model consistent with W3C Level 1 DOM.

  • http://www.mozilla.org/rdf/doc/api.html. The RDF Technical Overview; it provides an overview of the Mozilla RDF implementation.

  • http://www.mozilla.org/rdf/doc/vocabs.html/rdf/doc/vocabs.html. The Mozilla RDF metadata vocabularies.

You can also get more information about software support for RDF in Mozilla at these locations:

  • http://www.mozilla.org/rdf/doc/SmartBrowsing.html. Mozilla's SmartBrowsing system, which allows third-party metadata servers to provide XML/RDF "related link" annotations.

  • http://www.mozilla.org/rdf/doc/aurora.html. Mozilla's Aurora project, which is the code name for the user interface in Mozilla that handles RDF data sources.

  • http://www.mozilla.org/rdf/doc/flash-spec.html. The Mozilla Flash Specification. The Flash system offers an XML/RDF system for offering up-to-the-minute information about events that are of interest to the user.

  • http://www.mozilla.org/rdf/doc/z3950.html. The Mozilla RDF/Z39.50 Integration Project, which lets you connect to digital library systems. This project is all about using the ANSI/NISO Z39.50 search protocol from inside Mozilla.

What about RDF support in Internet Explorer? There really isn't any at least, not yet. However, Microsoft does offer an RDF viewer at http://msdn.microsoft.com/downloads/samples/Internet/xml/xml_rdf_viewer/sample.asp. (Keep in mind that Microsoft URIs seem to change every 15 minutes, so this link may be obsolete by the time you read this.)

Here's Microsoft's description of the RDF viewer:

The sample is written in Visual Basic 6.0 and consists of a single form. Users can enter the URL of a known RDF file or they can choose buttons that represent RDF files from three different sources. The form then retrieves the RDF file, which is then parsed using the MSXML parser. The contents of the RDF file are presented in a list box and any URL links attached to each item are stored in an array. When an item in the list box is selected, the page represented by the associated URL is displayed in the browser control.

To run the viewer, however, you need Internet Explorer 5.0, Visual Basic 6.0, and Windows 98, Windows NT 4.0, or Windows 2000.

As you can see, there's a lot of material out there on RDF. It's time to get to the RDF details now, starting with RDF syntax.

RDF Syntax

RDF documents are made of RDF statements that describe resources. Each statement has three parts, so it's called a triple. Here are the three parts of an RDF statement:

  • Resource. Resources are typically Web documents that you point to with a URI.

  • Named property. Such a property is a specific characteristic or attribute of the resource, such as the resource's creator.

  • Property value. The value of the property is the property's content. For example, the value of the <Creator> property is usually the name of the resource's creator.

An RDF statement, then, is made up of a resource, a named property, and a property value. In RDF, you name these three parts like this:

  • The resource is called the subject of the statement.

  • The named property is called the predicate of the statement.

  • The property value is called the object of the statement.

Here's a simple example RDF document:

<?xml version="1.0" ?> <rdf:RDF     xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">     <rdf:Description about="http://www.starpowder.com/planets.html">         <Creator>Nicolas Copernicus</Creator>     </rdf:Description>

In this case, the subject is the document "http://www.starpowder.com/planets.html", the predicate is the named property Creator, and the object is the name of the document's creator, Nicolas Copernicus. To understand RDF, I'm going to take this document apart piece by piece now.

The RDF Root Element

Because RDF documents are also XML documents, they start with the <?xml?> declaration. These documents also must have a specific root element, <RDF>, which encloses the rest of the document. Because the namespace you use with RDF is usually given the prefix rdf, you often specify the <RDF> element as <rdf:RDF>, like this:

<?xml version="1.0" ?> <rdf:RDF         .         .         . </rdf:RDF>

Also, note that RDF documents must use the RDF namespace.

The RDF Namespace

The official, W3C-defined, RDF namespace is "http://www.w3.org/1999/02/22-rdf-syntax-ns#" (the # on the end, which may look pretty funny, is not an error; it's there to help applications create valid XPointers). All RDF documents must use this namespace. The conventional prefix for this namespace is rdf, so I'll declare that prefix like this:

<?xml version="1.0" ?> <rdf:RDF     xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">         .         .         . </rdf:RDF>

The RDF Description Element

Each resource that you want to describe in RDF gets its own <rdf:Description> element. This element has several attributes:

Attribute Description
about Lets you specify what resource the element describes
aboutEach Lets you make statements about each of the element's children
aboutEachPrefix Lets you select RDF container items by prefix
bagID Specifies the ID of an associated bag container
ID Lets you give the element an ID value
type Specifies the description's type

In fact, you can also convert the properties you list in the <rdf:Description> element into attributes, as we'll see when we take a look at the RDF abbreviated syntax.

In our example, the resource being described is the document "http://www.starpowder.com/planets.html", so I assign that URI to the about attribute of the <rdf:Description> element:

<?xml version="1.0" ?> <rdf:RDF     xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">     <rdf:Description about="http://www.starpowder.com/planets.html">     .     .     .     </rdf:Description> </rdf:RDF>

In other words, you use the about attribute to specify the statement's subject.

To actually say something about the resource, you use property elements.

RDF Property Elements

Inside the <rdf:Description> element, you store the actual elements that describe the subject. In the current example, the predicate is the Creator property, which specifies the document's author, and the object is the name of the author, Nicolas Copernicus:

<?xml version="1.0" ?> <rdf:RDF     xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">     <rdf:Description about="http://www.starpowder.com/planets.html">         <Creator>Nicolas Copernicus</Creator>     </rdf:Description> </rdf:RDF>

The Creator property is not built into the RDF specification in fact, no properties are. It's up to you to create the named properties you want to use to describe a resource. In fact, a number of property sets, called RDF content description models, already are available. That's useful because they provide some agreement on property names which means that applications such as Web search engines can make some sense out of the properties you use. The most popular and well-supported of these RDF content description models is the Dublin Core.

The Dublin Core

The Dublin Core calls itself a "metadata initiative," and it provides an RDF content model that is in wide use to describe Web resources. The Dublin Core has attracted the attention of museums, libraries, government agencies, and commercial groups as a way of standardizing RDF for Web resources. You can find out all about the Dublin Core at its home page, http://www.purl.org/dc.

In the previous example, I used a <Creator> property, without specifying a namespace for that property. However, when you create your own properties, you should use a namespace to avoid conflicts. The Dublin Core's namespace is "http://purl.org/DC/". In fact, the <Creator> property I've been using is modeled after the Dublin Core's <Creator> property. I can declare the Dublin Core's namespace which is usually given the prefix dc in the example document, and indicate that <Creator> is part of that namespace, like this:

<?xml version="1.0" ?> <rdf:RDF     xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"     xmlns:dc="http://purl.org/DC/">     <rdf:Description about="http://www.starpowder.com/planets.html">         <dc:Creator>Nicolas Copernicus</dc:Creator>     </rdf:Description> </rdf:RDF>

The <Creator> property is just one Dublin Core property; you can find all the defined Dublin Core properties in Table 18.1.

Table 18.1. Dublin Core Properties
Element Description
Contributor Names the person or organization that has contributed in some way to this resource.
Coverage Gives the extent or scope of the content of the resource. For example, this might include location, time, or jurisdiction.
Creator Names the person, organization, or service responsible for creating the resource. Typically it refers to the resource's author.
Date Gives a date connected to the resource, such as its last update or its creation date. The recommended practice for encoding the date value is defined in ISO 8601, which follows the YYYY-MM-DD format.
Description Gives the description of the resource. For example, this could be an abstract, table of contents, or text description of the resource.
Format Gives the format used for the resource. Usually, the format includes the media type or dimensions of the resource. Readers may use Format to determine the software, hardware, or other equipment needed. You usually use a MIME type here.
Identifier Gives an ID value for the resource in its context. Recommended practice is to identify the resource by means of a string or number as part of a formal identification system. For example, you might use a URI or an International Standard Book Number (ISBN).
Language Specifies the language of the resource. Recommended practice is to use values defined by RFC 1766, which includes a two-letter Language Code (from the ISO 639 standard), with an optional two-letter Country Code (from the ISO 3166 standard).
Publisher Names the agent responsible for making the resource available. Usually, this is a person, an organization, or a service.
Relation Is a reference to a related resource or relationship type.
Rights Gives information about rights about the resource. For example, a Rights element can contain intellectual property rights, copyright, or various other property rights.
Source Refers to a resource from which the current resource is derived.
Subject Gives the topic of the content of the resource. Recommended practice is to select a value from a formal classification scheme. For example, subjects might be keywords, key phrases, or classification codes.
Title Is a name given to the resource.
Type Gives the type of the content of the resource, usually a term describing general categories or functions. Recommended practice is to select a value from a formally defined and publicly available vocabulary.

Each Dublin Core element also 10 ten attributes, which are taken from the ISO/IEC 11179 standard:

Attribute Description
Comment Is a comment about the use of the data in the element
Datatype Specifies the type of data in the element
Definition Defines the concept behind the data in the element
Identifier Is a unique identifier assigned to the element that identifies it
Language Specifies the language of the data in the element
Maximum Occurrence Puts a limit on how many times the element may occur
Name is the name you've assigned to the data element
Obligation Specifies whether the element is required
Registration Authority Refers to the agency or group authorized to register the element
Version Gives the version of the element

In fact, 6 of these 10 attributes are common to all the Dublin Core elements, and they have fixed values. Here they are, along with their values:

Attribute Value
Version 1.1
Registration Authority Dublin Core Metadata Initiative
Language en (that is, English)
Obligation Optional
Datatype Character String
Maximum Occurrence Unlimited

The Dublin Core also lists a set of default resource types that you can use with the <Type> element:

  • collection

  • dataset

  • event

  • image

  • interactive resource

  • model

  • party

  • physical object

  • place

  • service

  • software

  • sound

  • text

You can find these types defined in detail at http://purl.org/DC/documents/wd-typelist.htm.

Describing Multiple Properties

The example RDF document that we've seen so far has defined only one property for the "http://www.starpowder.com/planets.html" resource the <Creator> property. In fact, you can assign multiple properties to resources, and now that we've seen all the available Dublin Core elements, I'll put more of them to work. For example, here's how I describe that resource's creator, title, and type:

<?xml version="1.0" ?> <rdf:RDF     xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"     xmlns:dc="http://purl.org/DC/">     <rdf:Description about="http://www.starpowder.com/planets.html">         <dc:Creator>Nicolas Copernicus</dc:Creator>         <dc:Title>Mercury</dc:Title>         <dc:Type>text</dc:Type>     </rdf:Description> </rdf:RDF>

Describing Multiple Resources

An RDF document can also describe multiple resources all you have to do is use multiple <rdf:Description> elements. For example, here's an RDF document that describes three resources, mercury.html, venus.html, and earth.html:

<?xml version="1.0" ?> <rdf:RDF     xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"     xmlns:dc="http://purl.org/DC/">      <rdf:Description about="http://www.starpowder.com/mercury.html">         <dc:Creator>Nicolas Copernicus</dc:Creator>         <dc:Title>Mercury</dc:Title>         <dc:Type>text</dc:Type>     </rdf:Description>     <rdf:Description about="http://www.starpowder.com/venus.html">         <dc:Creator>Nicolas Copernicus</dc:Creator>         <dc:Title>Venus</dc:Title>         <dc:Type>text</dc:Type>     </rdf:Description>     <rdf:Description about="http://www.starpowder.com/earth.html">         <dc:Creator>Nicolas Copernicus</dc:Creator>         <dc:Title>Earth</dc:Title>         <dc:Type>text</dc:Type>     </rdf:Description>> </rdf:RDF>

Nesting Resources

What if a property itself needs more description? For example, what if the creator of the resource is described by a Web page, and you want to refer the reader to that page? In that case, you can nest <rdf:Resource> elements. For example, if you want to describe Nicolas Copernicus, the creator of planets.html, with another Web page, NickC.html, that might look like this:

<?xml version="1.0" ? <rdf:RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"     xmlns:dc="http://www.purl.org/DC/">     <rdf:Description about="http://www.starpowder.com/planets.html">         <dc:Title>Mercury</dc:Title>         <dc:Creator>             <rdf:Description about="http://www.starpowder.com/NickC.html">                  <dc:Title>Nicolas Copernicus</dc:Title>                  <dc:Language>en</dc:Language>             </rdf:Description>         </dc:Creator>     </rdf:Description> </rdf:RDF>

Referring to Resources by Reference

There's another way to refer to a resource that describes a property you can give the resource's URI using the rdf:resource attribute. You use this attribute in the property element. Here's an example; in this case, I'm referring to the resource NickC.html to describe the creator of various documents:

<?xml version="1.0" ?> <rdf:RDF     xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"     xmlns:dc="http://www.purl.org/DC/">     <rdf:Description about="http://www.starpowder.com/mercury.html">         <dc:Title>Mercury</dc:Title>         <dc:Creator rdf:resource="http://www.starpowder.com/NickC.html"/>     </rdf:Description>     <rdf:Description about="http://www.starpowder.com/venus.html">         <dc:Title>Venus</dc:Title>         <dc:Creator rdf:resource="http://www.starpowder.com/NickC.html"/>     </rdf:Description>     <rdf:Description about="http://www.starpowder.com/earth.html">         <dc:Title>Earth</dc:Title>         <dc:Creator rdf:resource="http://www.starpowder.com/NickC.html"/>     </rdf:Description> </rdf:RDF>

As you can see, using the rdf:resource attribute makes it easy to connect the same property to a number of resources; in this case, I'm giving the mercury.html, venus.html, and earth.html all the same creator properties.

Using XML in Property Elements

Although property values are mostly text or resources that you reference, they can also be straight XML. In that case, you just set the parseType attribute of the property to "Literal".

For example, I'm using my own XML elements, such as <BirthCity> and <BirthCountry> in the <Creator> property here, and giving them their own namespace, ns:

<?xml version="1.0" ?> <rdf:RDF     xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"     xmlns:dc="http://www.purl.org/DC/"     xmlns:ns="http://www.starpowder.com/namespace/">     <rdf:Description about="http://www.starpowder.com/planets.html">         <dc:Creator parseType="Literal">             <ns:FirstName>Nicolas</nm:FirstName>             <ns:LastName>Copernicus</nm:LastName>             <ns:Birth>1473</nm:Birth>             <ns:Death>1543</nm:Death>             <ns:BirthCity>Torun</nm:BirthCity>             <ns:BirthCountry>Poland</nm:BirthCountry>         </dc:Creator>     </rdf:Description> </rdf:RDF>

Using Abbreviated RDF Syntax

The W3C also defines an abbreviated RDF syntax to make things a little easier. To use the abbreviated syntax, you just convert property elements to attributes of the <rdf:Description> element. For example, here's what an unabbreviated document might look like:

<?xml version="1.0" ?> <rdf:RDF     xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"     xmlns:dc="http://purl.org/DC/">     <rdf:Description about="http://www.starpowder.com/mercury.html">         <dc:Creator>Nicolas Copernicus</dc:Creator>         <dc:Title>Mercury</dc:Title>         <dc:Type>text</dc:Type>     </rdf:Description>     <rdf:Description about="http://www.starpowder.com/venus.html">         <dc:Creator>Nicolas Copernicus</dc:Creator>         <dc:Title>Venus</dc:Title>         <dc:Type>text</dc:Type>     </rdf:Description>     .     .     .

Here's the abbreviated form:

<?xml version="1.0" ?> <rdf:RDF     xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"     xmlns:dc="http://purl.org/DC/">      <rdf:Description about="http://www.starpowder.com/mercury.html"         dc:Creator = "Nicolas Copernicus"         dc:Title = "Mercury"         dc:Type = "text">     </rdf:Description>     <rdf:Description about="http://www.starpowder.com/venus.html"         dc:Creator = "Nicolas Copernicus">         dc:Title = "Venus"         dc:Type = "text">     </rdf:Description>     .     .     .

Why is this useful? One big reason is that it makes RDF easier to handle in HTML browsers in case that RDF is embedded in an HTML document. Recall that HTML browsers will ignore any tags they don't understand and simply treat the element's content as plain text. If you convert the property elements to attributes, there are no property elements to be mishandled in that way.

The situation is a little more complex if your properties themselves contain resources. In that case, it's best to refer to those resources by reference using the rdf:resource attribute:

<?xml version="1.0" ?> <rdf:RDF     xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"     xmlns:dc="http://www.purl.org/DC/">     <rdf:Description about="http://www.starpowder.com/mercury.html"         dc:Title = "Mercury">         <dc:Creator rdf:resource="http://www.starpowder.com/NickC.html"/>     </rdf:Description>     <rdf:Description about="http://www.starpowder.com/venus.html"         dc:Title = "Venus">         <dc:Creator rdf:resource="http://www.starpowder.com/NickC.html"/>     </rdf:Description>     .     .     .

Even though this still uses <dc:Creator> property elements, there is still no element content to be treated as plain text by an HTML browser.

RDF Containers

RDF also enables you to group properties together by defining property containers. Three containers exist:

Container Description
Bag A group of properties without any particular order.
Seq A sequence of properties in a specific order.
Alt A list of properties giving alternate choices. Only one of all these choices is actually chosen.

These containers are supported with the <rdf:Bag>, <rdf:Seq>, and <rdf:Alt> elements, which have ID and aboutEach attributes. (The W3C RDF syntax specification mistakenly defines these elements with only an ID attribute, but then uses both attributes in the text). I'll use both those attributes in this chapter.

Using the Bag Container

You use a Bag container to indicate that a property has multiple, although unordered, values. How do you specify the multiple items in a container? You use the <rdf:li> element (modeled after the HTML <LI>, list item, element).

Here's an example; in this case, I'm indicating that the planets.html resource has multiple subjects Mercury, Venus, Mars, and Earth:

<?xml version="1.0" ?> <rdf:RDF     xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"     xmlns:dc="http://www.purl.org/DC#">     <rdf:Description about="http://www.starpowder.com/planets.html">         <dc:Title>Planets</dc:Title>         <dc:Creator>Nicolas Copernicus</dc:Creator>         <dc:Type>text</dc:Type>         <dc:Subject>             <rdf:Bag>                 <rdf:li>Mercury</rdf:li>                 <rdf:li>Venus</rdf:li>                 <rdf:li>Earth</rdf:li>                 <rdf:li>Mars</rdf:li>             </rdf:Bag>         </dc:Subject>     </rdf:Description> </rdf:RDF>

The items in a bag can also be resource references, of course, like this:

<?xml version="1.0" ?> <rdf:RDF     xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"     xmlns:dc="http://www.purl.org/DC#">     <rdf:Description about="http://www.starpowder.com/planets.html">         <dc:Title>Planets</dc:Title>         <dc:Creator>Nicolas Copernicus</dc:Creator>         <dc:Subject>             <rdf:Bag>                 <rdf:li                     rdf:resource="http://www.starpowder.com/mercury.html"/>                 <rdf:li                     rdf:resource="http://www.starpowder.com/venus.html"/>                 <rdf:li                     rdf:resource="http://www.starpowder.com/earth.html"/>                 <rdf:li                     rdf:resource="http://www.starpowder.com/mars.html"/>             </rdf:Bag>         </dc:Subject>     </rdf:Description> </rdf:RDF>

Using the Seq Container

You use a Seq to indicate that a property has multiple ordered values. In this case, you are indicating that the multiple property values have some order. For example, this document indicates that planet.html covers the topics Mercury, Venus, Earth, and Mars, in that order:

<?xml version="1.0" ?> <rdf:RDF     xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"     xmlns:dc="http://www.purl.org/DC#">     <rdf:Description about="http://www.starpowder.com/planets.html">         <dc:Title>Planets</dc:Title>         <dc:Creator>Nicolas Copernicus</dc:Creator>         <dc:Subject>             <rdf:Seq>                 <rdf:li>Mercury</rdf:li>                 <rdf:li>Venus</rdf:li>                 <rdf:li>Earth</rdf:li>                 <rdf:li>Mars</rdf:li>             </rdf:Seq>         </dc:Subject>     </rdf:Description> </rdf:RDF>

Using the Alt Container

The Alt container provides alternatives, such as different language versions of a resource, or mirror sites. In general, you use it to associate alternative resources with a document. Here's an example; in this case, I'm listing various versions of a document in different formats, plain text, HTML, Rich Text Format (RTF), and XML:

<?xml version="1.0" ?> <rdf:RDF     xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"     xmlns:dc="http://www.purl.org/DC#">     <rdf:Description about="http://www.starpowder.com/planets">         <dc:Title>Planets</dc:Title>         <dc:Creator>Nicolas Copernicus</dc:Creator>         <dc:Format>             <rdf:Alt>                 <rdf:li resource =                  "http://www.starpowder.com/planets.html">                      text/html                 </rdf:li>                 <rdf:li resource =                  "http://www.starpowder.com/planets.txt">                     text/plain                 </rdf:li>                 <rdf:li resource =                  "http://www.starpowder.com/planets.rtf">                     text/rtf                 </rdf:li>                 <rdf:li resource =                  "http://www.starpowder.com/planets.xml">                     text/xml                 </rdf:li>             </rdf:Alt>         </dc:Format>     </rdf:Description> </rdf:RDF>

Making Statements About Containers

You can use a container's ID attribute to make a statement about the container as a whole, separate from the items in the container. Here's an example. In this case, I'm giving a creation date for a bag container; to do that, I give the bag container the ID "planets" and then create a new <rdf:Description> element about "#planets" to describe the bag container and give its date:

<?xml version="1.0" ?> <rdf:RDF     xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"     xmlns:dc="http://www.purl.org/DC#">     <rdf:Description         about="http://www.starpowder.com/planets.html">         <dc:Title>XML Links</dc:Title>         <dc:Creator>Nicolas Copernicus</dc:Creator>         <dc:Subject>             <rdf:Bag ID="planets">                 <rdf:li                     rdf:resource="http://www.starpowder.com/mercury.html"/>                 <rdf:li                     rdf:resource="http://www.starpowder.com/venus.html"/>                 <rdf:li                     rdf:resource="http://www.starpowder.com/earth.html"/>                 <rdf:li                     rdf:resource="http://www.starpowder.com/mars.html"/>             </rdf:Bag>         </dc:Subject>     </rdf:Description>     <rdf:Description about="#planets">         <dc:Date>             1501-10-15         </dc:Date>     </rdf:Description> </rdf:RDF>

Making Statements About the Items in a Container

You can also make statements about each item in a container by using the container's aboutEach attribute. For example, suppose that I want to indicate that each item in a bag has the same creation date; in that case, I could assign the value "creationDate" to the bag's aboutEach attribute, and add a new <rdf:Description> element about "#creationDate", like this:

<?xml version="1.0" ?> <rdf:RDF     xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"     xmlns:dc="http://www.purl.org/DC#">     <rdf:Description about="http://www.starpowder.com/planets.html">         <dc:Title>Mercury</dc:Title>         <dc:Creator>Nicolas Copernicus</dc:Creator>         <dc:Subject>             <rdf:Bag aboutEach="creationDate">                 <rdf:li                     resource="http://www.starpowder.com/mercury.html"/>                 <rdf:li             resource="http://www.starpowder.com/venus.html"/>                 <rdf:li                     resource="http://www.starpowder.com/earth.html"/>                 <rdf:li                 resource="http://www.starpowder.com/mars.html"/>             </rdf:Bag>         </dc:Subject>     </rdf:Description>     <rdf:Description aboutEach="#creationDate">         <dc:Date>             1501-10-15         </dc:Date>     </rdf:Description> </rdf:RDF>

Selecting Container Items by Prefix

In fact, you can make statements about groups of resources that have the same prefixes (which may or may not be members of one container). For example, say that I want to connect a date with all resources that start with "http://www.starpowder.com/". I can do that with the aboutEachPrefix attribute of <rdf:Description>, like this:

<?xml version="1.0" ?> <rdf:RDF     xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"     xmlns:dc="http://www.purl.org/DC#">     <rdf:Description about="http://www.starpowder.com/planets.html">         <dc:Title>Mercury</dc:Title>         <dc:Creator>Nicolas Copernicus</dc:Creator>         <dc:Subject>             <rdf:Bag>                 <rdf:li                     resource="http://www.starpowder.com/mercury.html"/>                 <rdf:li             resource="http://www.starpowder.com/venus.html"/>                 <rdf:li                     resource="http://www.starpowder.com/earth.html"/>                 <rdf:li                 resource="http://www.starpowder.com/mars.html"/>             </rdf:Bag>         </dc:Subject>     </rdf:Description>     <rdf:Description aboutEachPrefix="#http://www.starpowder.com/">         <dc:Date>             1501-10-15         </dc:Date>     </rdf:Description> </rdf:RDF>

Creating RDF Schemas

So far, the property elements you use in RDF are up to you to define, unless you use someone else's RDF content model, such as the Dublin Core. Until recently, there was no real way to make sure that RDF software would be capable of checking the syntax of your RDF extensions.

However, the W3C has been working hard on creating an RDF schema language, and you can find the details at http://www.w3.org/TR/rdf-schema. It's not finalized yet (the specification is a candidate recommendation at this writing) and is not supported by any software, but when available, it will let RDF parsers check the full syntax of the extensions you make to RDF.

The Dublin Core Metatdata Initiative is solidly behind the idea of creating schemas to let RDF software check the syntax of RDF documents; you can read the group's thoughts on the matter at http://purl.org/DC/schemas/index.htm. Here's a partial extract from that page:

The diversity of metadata needs on the Web requires an infrastructure that supports the coexistence of complementary, independently maintained metadata packages. The World Wide Web Consortium (W3C) has begun implementing an architecture for metadata for the Web. The Resource Description Framework, or RDF, is designed to support the many different metadata needs of vendors and information providers. The Dublin Core Metadata Initiative expects to support the infrastructure for registries provided by RDF Schemas. Developments in this area will be reflected on these pages as they develop.

CDF Overview

Channel Definition Format (CDF) is a Microsoft XML application for use with Internet Explorer. As mentioned in the introduction to this chapter, CDF enables automatic user notification when a Web site changes.

XML and Microsoft

XML has been steadily gaining support at Microsoft over the years. As of this writing, Microsoft has just indicated that the next version of Visual Studio, which is the host for such products as Visual Basic and Visual C++, is going to rely heavily on XML, as will MS Office applications.

How does CDF look in practice? Take a look at Figure 18.3. There, I've added a channel named Planets, complete with a simple icon, to Internet Explorer. To see the available channels, you click the Favorites button in Internet Explorer's button bar, which opens the Favorites bar as you see in Figure 18.3. (You can close the Favorites bar by clicking the X button at upper right in the bar.) The top folder in the Favorites bar is the Channels folder, which you click to open. The Channels bar shows the current channels, and the user has only to click a channel to download the channel's main page (channels can represent not only single pages, but whole Web sites).

Figure 18.3. Internet Explorer showing a new channel.

graphics/18fig03.gif

That's how channels work when activated, the page or pages they represent are downloaded so that they may be viewed by the user without additional fetches from the Internet, even offline. Channel content may be downloaded on demand or on a set schedule. Besides a main page, most channels include a collection of other pages; we'll see how to create channel children, and how the user can access them, later in this chapter (see the later section "Adding <ITEM> Children").

How do channels actually work? The complete specification for a channel is stored in a CDF document, which is separate from other Web pages but usually linked to one of those Web pages. The user has only to open the CDF file which usually means clicking a hyperlink with the text Subscribe to this page or something similar to establish the channel in Internet Explorer. They can delete the channel later by removing it from the Favorites bar (for example, by right-clicking the channel and selecting the Delete item).

A fair number of CDF resources are available, nearly all of them at Microsoft. Microsoft did submit the specification for CDF to the W3C, and the W3C seems to have politely accepted it, posted it on its Web site, and done nothing else with it. Here's a starter list of CDF resources keep in mind that Microsoft URIs change very frequently:

  • http://msdn.microsoft.com/workshop/delivery/cdf/reference/CDF.asp. The CDF reference at Microsoft.

  • http://www.w3.org/TR/NOTE-CDFsubmit.html. The Microsoft-submitted CDF note giving the CDF specification, now at the W3C.

  • http://support.microsoft.com/support/kb/articles/Q174/6/87.ASP. An article on creating personalized channels using Active Server Pages (ASP) with Microsoft Internet Information Server (IIS). All about how content providers can dynamically generate custom CDF files to send personalized information to users, taking into account user preferences.

  • http://msdn.microsoft.com/downloads/tools/cdfgen/cdfgenerator.asp. An automatic CDF generator.

  • http://support.microsoft.com/support/kb/articles/Q241/8/39.ASP. A discussion on how to create a CDF file that works with Microsoft FrontPage 2000.

  • http://msdn.microsoft.com/workshop/delivery/channel/tutorial/tutorial.asp. Microsoft's CDF tutorial.

We might also note that Microsoft has a CDF generator; you can use this generator, which is free to download, to create CDF files. Here's how Microsoft describes it:

  • It has a simple and intuitive graphical interface that you will get used to in a few minutes.

  • It doesn't require previous knowledge of channels.

  • It supports all CDF tags.

  • It supports UTF-8 encoding.

  • It can also be used for testing purposes because it parses the CDF files and detects the errors.

  • It supports drag and drop, so there's less to type.

Microsoft also has another tool, which is even easier to use the Channel Wizard. As of this writing, it is at http://msdn.microsoft.com/workshop/delivery/channel/cdfwiz/intro.asp. This tool lets you construct channels without knowing the first thing about CDF. This wizard asks you questions about the channel you want and generates the .cdf file and the link to it that you can embed in a Web page. This tool runs entirely online, and you can see it at work in Figure 18.4.

The Channel Wizard also provides dynamic HTML samples that will allow you to add special effects to your channel pages.

Microsoft supports the CDF File Verification Tool, which checks CDF files for validity, as well. As of this writing, this tool is at http://msdn.microsoft.com/downloads/tools/cdftest/cdftest.asp. You can use this tool to discover problems with CDF files, such as missing end tags and incorrect or misspelled tags. However, it doesn't run online; you must download this tool to use it.

That gives us an overview of CDF it's time to start creating CDF files and channels.

Figure 18.4. The Microsoft Channel Wizard.

graphics/18fig04.gif

CDF Syntax

CDF files are true XML documents. They must be well-formed, but they can't be valid because there is no current publicly available CDF DTD or schema. There is an early CDF DTD in the CDF note at the W3C, at http://www.w3.org/TR/NOTE-CDFsubmit.html, but it's out of date. However, you can see how simple it is it's almost trivial, which suggests that you can create your own CDF DTD easily enough. (Note that several of these elements no longer exist and that others have been added.)

<!ELEMENT LastMod EMPTY> <!ATTLIST LastMod VALUE CDATA #REQUIRED> <!ELEMENT Title EMPTY> <!ATTLIST Title VALUE CDATA #REQUIRED> <!ELEMENT Abstract EMPTY> <!ATTLIST Abstract VALUE CDATA #REQUIRED> <!ELEMENT Author EMPTY> <!ATTLIST Author VALUE CDATA #REQUIRED> <!ELEMENT Publisher EMPTY> <!ATTLIST Publisher VALUE CDATA #REQUIRED> <!ELEMENT Copyright EMPTY> <!ATTLIST Copyright VALUE CDATA #REQUIRED> <!ELEMENT PublicationDate EMPTY> <!ATTLIST PublicationDate VALUE CDATA #REQUIRED> <!ELEMENT Keywords EMPTY> <!ATTLIST Keywords VALUE CDATA #REQUIRED> <!ELEMENT Category EMPTY> <!ATTLIST Category VALUE CDATA #REQUIRED> <!ELEMENT Rating EMPTY> <!ATTLIST Rating PICS-Label CDATA #REQUIRED>

Note that because CDF files are XML documents, you must escape the characters <, , ', ", and & as &lt;, &gt;, &apos;, &quot;, and &amp;, respectively, in CDF files.

Here are all the CDF elements:

Element Description
<?XML?> Is the XML declaration.
<A> Creates a hyperlink.
<ABSTRACT> Gives abstract text for the channel; appears in ToolTips.
<CHANNEL> Creates a channel.
<EARLIESTTIME> Gives the earliest time for updates.
<HTTP-EQUIV> Supplies information that can also be provided through HTTP response headers.
<INTERVALTIME> Specifies the time between updates.
<ITEM> Is a Web document that is part of the channel.
<LATESTTIME> Gives the latest time for updates.
<LOG> Indicates that the URL of the parent ITEM should be recorded in a page-hit log file.
<LOGIN> Indicates that the channel requires authentication for updates.
<LOGO> Are images to be used for the channel in Internet Explorer
<LOGTARGET> Indicates where to send a CDF client page-hit log file.
<PURGETIME> Indicates the maximum age of valid page hits when the log file is being uploaded.
<SCHEDULE> Sets the schedule used for channel updating.
<TITLE> Gives the title of the channel, for the Favorites bar.
<USAGE> Indicates how the parent element should be used. Can be set to "Channel", "DesktopComponent", "Email", "NONE", "ScreenSaver", or "SoftwareUpdate".

When you create a channel, you must decide what page or pages to include in the channel. As we'll see, you can include as many pages as you'd like in a channel, all of which may be downloaded to the user's computer. In this chapter, I'll use a simple HTML document, planets.html (refer to Figure 18.3):

<HTML>     <HEAD>         <TITLE>             The Planets         </TITLE>     </HEAD>      <BODY>         <CENTER>             <H1>                 Welcome to the Planets!             </H1>             <BR>             This is where you'll find all things planetary.         </CENTER>     </BODY> </HTML>

After you've decided what will be in your channel, you must create the CDF file that will define that channel.

Creating a CDF File

Here's just about the simplest possible CDF file for planets.html, which I'll call planets.cdf:

<?xml version="1.0"?> <CHANNEL HREF="http://www.starpowder.com/planets.html"> </CHANNEL>

This example just creates the most basic possible channel, based on a single Web page. The user has to click the channel to be able to download any content because we haven't set up a schedule for automatic updating yet.

As you can see, this document is a very simple one all you need is the XML declaration and a <CHANNEL> element. The <CHANNEL> element uses a single attribute, HREF, to specify the URI of a page that will become the channel's main page, displayed in Internet Explorer when the user clicks the channel (refer to Figure 18.3).

On the other hand, most channels aren't made up of a single page, but rather several pages. You add those pages with the <ITEM> element.

Adding <ITEM> Children

To add child pages to a channel, you use the <ITEM> element. For example, say that I want to keep planets.html as the main page for the channel, but I want to add child pages for various planets: mercury.html, venus.html, earth.html, and venus.html. I can do that with the <ITEM> element, setting that element's HREF attribute to the URI of each child page in turn:

<?xml version="1.0"?> <CHANNEL HREF="http://www.starpowder.com/planets.html">     <ITEM HREF="http://www.starpowder.com/mercury.html">     </ITEM>     <ITEM HREF="http://www.starpowder.com/venus.html">     </ITEM>     <ITEM HREF="http://www.starpowder.com/earth.html">     </ITEM>     <ITEM HREF="http://www.starpowder.com/venus.html">     </ITEM> </CHANNEL>

Now we have five pages in this channel. So how do you install this channel in Internet Explorer?

Connecting a CDF File to a Web Page

To subscribe to a channel, the user only needs to open the channel's CDF file. You usually link to a CDF file and let the user subscribe to your channel simply by clicking the link. For example, here's how I might add such a hyperlink to planets.html note that the target of the hyperlink is simply the CDF file, planets.cdf:

<HTML>     <HEAD>         <TITLE>             The Planets         </TITLE>     </HEAD>     <BODY>         <CENTER>             <H1>                 Welcome to the Planets!             </H1>             <BR>             This is where you'll find all things planetary.             <BR>             <A HREF="planets.cdf">Subscribe to this page!</A>         </CENTER>     </BODY> </HTML>

Now when the user clicks the link, Internet Explorer informs the user that a new page, corresponding to this channel, will be added to the Favorites list, as you see in Figure 18.5.

Figure 18.5. Subscribing to a channel.

graphics/18fig05.gif

So far, so good we've created a channel with a main page and four children. Note that the name of the channel in Figure 18.5 is simply the name of the page because we haven't given the channel a title. I'll do that next.

Describing a Channel

You can describe a channel to a user in three ways with titles, abstracts, and logos. I'll take a look at those possibilities in order.

Channel Titles

If you give a channel a title, that title will appear in the Favorites bar. You can also give a title to each child page in the channel. All this happens with the <TITLE> element. For example, here's how I add a title to the channel and all the child pages in planets.cdf:

<?xml version="1.0"?> <CHANNEL HREF="http://www.starpowder.com/planets.html">     <TITLE>Planets</TITLE>     <ITEM HREF="http://www.starpowder.com/mercury.html">         <TITLE>All about Mercury</TITLE>     </ITEM>     <ITEM HREF="http://www.starpowder.com/venus.html">         <TITLE>All about Venus</TITLE>     </ITEM>     <ITEM HREF="http://www.starpowder.com/earth.html">         <TITLE>All about Earth</TITLE>     </ITEM>     <ITEM HREF="http://www.starpowder.com/mars.html">         <TITLE>All about Mars</TITLE>     </ITEM> </CHANNEL>

You can see the results in Figure 18.6 as you can see, all the pages in the channel now have easily readable titles. If the user is interested in updating any of these pages, he or she must only click them.

Figure 18.6. Channels with titles.

graphics/18fig06.gif

Besides using titles, you can also add abstracts to the pages in a channel.

Channel Abstracts

Channel titles are fine, but necessarily brief. A channel abstract can hold more information about the channel, but its text must also be fairly brief because that text appears in a ToolTip (one of those small yellow boxes with explanatory text that appear near the mouse pointer) for the associated channel page.

You can create an abstract for a page in a channel with the <ABSTRACT> element. For example, I can add abstracts to the various pages in the Planets channel like this:

<?xml version="1.0"?> <CHANNEL HREF="http://www.starpowder.com/planets.html">     <TITLE>Planets</TITLE>     <ITEM HREF="http://www.starpowder.com/mercury.html">         <TITLE>All about Mercury</TITLE>         <ABSTRACT>             All planetary information for             Mercury, including orbital specifications.         </ABSTRACT>     </ITEM>     <ITEM HREF="http://www.starpowder.com/venus.html">         <TITLE>All about Venus</TITLE>         <ABSTRACT>             All planetary information for             Venus, including orbital specifications.         </ABSTRACT>     </ITEM>     <ITEM HREF="http://www.starpowder.com/earth.html">         <TITLE>All about Earth</TITLE>         <ABSTRACT>             All planetary information for             Earth, including orbital specifications.         </ABSTRACT>     </ITEM>     <ITEM HREF="http://www.starpowder.com/mars.html">         <TITLE>All about Mars</TITLE>         <ABSTRACT>             All planetary information for             Mars, including orbital specifications.         </ABSTRACT>     </ITEM> </CHANNEL>

You can see the results in Figure 18.7, where you see an abstract displayed as a ToolTip.

Figure 18.7. Channels with abstracts.

graphics/18fig07.gif

Another way to describe a channel is with logos. We'll look at these next.

Channel Logos

You can add logos icons and images to channels, using the <LOGO> element to the <CHANNEL> or <ITEM> elements. You specify what type of logo you're creating with the STYLE attribute, which takes these values:

Value Description
ICON 16 x 16 pixel icon. This image appears in the Favorites bar hierarchy.
IMAGE 80 x 32 pixel image. In Active Desktop installations, this logo is placed in the desktop Channel bar, which provides quick access to the channel's main page.
IMAGE-WIDE 194 x 32 pixel image. Wide logos appear in the browser's Favorites bar to provide a link to the main channel page. When clicked, this image expands or contracts the channel's child list if the channel has children.

Here's an example where I'm adding logos to the Planets channel:

<?xml version="1.0"?> <CHANNEL HREF="http://www.starpowder.com/planets.html">     <TITLE>Planets</TITLE>     <LOGO HREF="http://www.starpowder.com/icon.gif" STYLE="ICON"/>     <LOGO HREF="http://www.starpowder.com/image.gif" STYLE="IMAGE"/>     <LOGO HREF="http://www.starpowder.com/image-wide.gif" STYLE="IMAGE-WIDE"/>     <ITEM HREF="http://www.starpowder.com/mercury.html">         <TITLE>All about Mercury</TITLE>         <ABSTRACT>             All planetary information for             Mercury, including orbital specifications.         </ABSTRACT>     </ITEM>     <ITEM HREF="http://www.starpowder.com/venus.html">         <TITLE>All about Venus</TITLE>         <ABSTRACT>             All planetary information for             Venus, including orbital specifications.         </ABSTRACT>     </ITEM>     <ITEM HREF="http://www.starpowder.com/earth.html">         <TITLE>All about Earth</TITLE>         <ABSTRACT>             All planetary information for             Earth, including orbital specifications.         </ABSTRACT>     </ITEM>      <ITEM HREF="http://www.starpowder.com/mars.html">         <TITLE>All about Mars</TITLE>         <ABSTRACT>             All planetary information for             Mars, including orbital specifications.         </ABSTRACT>     </ITEM> </CHANNEL>

The icon image for the planets channel a red circle has replaced the default icon for the channel (see Figure 18.8).

Figure 18.8. Replacing the Channel icon.

graphics/18fig08.gif

Scheduling Automatic Updates

You can set up a channel so that the browser downloads channel content automatically if it has been updated. (The browser relies on the Last-Modified item in the HTTP header of a Web page to check when the page was last modified.) I advise you to use this feature with caution few things annoy users more than when software such as Internet Explorer seems to take over by itself and do mysterious things.

You use a <SCHEDULE> element to create a channel schedule. This element has three attributes:

Attribute Description
STARTDATE Indicates when the schedule is to start.
STOPDATE Indicates when schedule is to end (if you don't use this attribute, the schedule never expires).
TIMEZONE Gives the difference in hours between the server's time zone and Greenwich Mean Time. For example, EST is -0500, CST is -0600, MST is -0700, PST -0800, and Alaska and Hawaii are -1000.

The <SCHEDULE> element can itself have three child elements:

Element Description
<INTERVALTIME> Is required. Indicates how often to check for updates. Has DAY (1 7), HOUR (0 23), and MIN (0 59) attributes.
<EARLIESTTIME> Indicates the earliest time to update. Has DAY (1 7), HOUR (0 23), and TIMEZONE (default is the user's timezone) attributes.
<LATESTTIME> Indicates the latest time to update. Has DAY (1 7), HOUR (0 23), and TIMEZONE (default is the user's timezone) attributes.

For example, say that I wanted to have Internet Explorer check once every five days if a channel's content has changed and so needs to be downloaded automatically, and I wanted to download new content only between 3 and 5 a.m. That looks like this:

<?xml version="1.0"?> <CHANNEL HREF="http://www.starpowder.com/planets.html">     <TITLE>Planets</TITLE>     <LOGO HREF="http://www.starpowder.com/icon.gif" STYLE="ICON"/>     <LOGO HREF="http://www.starpowder.com/image.gif" STYLE="IMAGE"/>     <LOGO HREF="http://www.starpowder.com/image-wide.gif"  STYLE="IMAGE-WIDE"/>     <SCHEDULE TIMEZONE="-0800">         <INTERVALTIME DAY="5"/>         <EARLIESTTIME HOUR="3" TIMEZONE="-0800"/>         <LATESTTIME HOUR="5" TIMEZONE="-0800"/>     </SCHEDULE>     <ITEM HREF="http://www.starpowder.com/mercury.html">         <TITLE>All about Mercury</TITLE>         <ABSTRACT>             All planetary information for             Mercury, including orbital specifications.         </ABSTRACT>     </ITEM>      <ITEM HREF="http://www.starpowder.com/venus.html">         <TITLE>All about Venus</TITLE>         <ABSTRACT>             All planetary information for             Venus, including orbital specifications.         </ABSTRACT>     </ITEM>     <ITEM HREF="http://www.starpowder.com/earth.html">         <TITLE>All about Earth</TITLE>         <ABSTRACT>             All planetary information for             Earth, including orbital specifications.         </ABSTRACT>     </ITEM>     <ITEM HREF="http://www.starpowder.com/mars.html">         <TITLE>All about Mars</TITLE>         <ABSTRACT>             All planetary information for             Mars, including orbital specifications.         </ABSTRACT>     </ITEM> </CHANNEL>

Again, you should be very cautious when setting up automatic updates they can be confusing to the user, who may get very annoyed and have no idea how to cancel such updating.

Turning Off Precaching

When channel content is downloaded, it is cached automatically so that the user may view it later. However, if you want to turn off precaching, you can set the <CHANNEL> element's PRECACHE attribute to "NO":

<CHANNEL PRECACHE="NO" HREF=...         .         .         . </CHANNEL>

If you do turn off precaching, nothing will be downloaded automatically from the channel.

Downloading Pages in a Hierarchy

You can also make Internet Explorer download a whole Web site, not just those pages listed in <ITEM> elements, although this can be very wasteful of bandwidth. To do this, you use the <CHANNEL> element's LEVEL attribute, which indicates how many levels deep in a page hierarchy you want the browser to fetch pages from (the hierarchy is constructed by linking pages with hyperlinks).

You can set LEVEL to values from 0 to 3, as here, where I set it to 2:

<?xml version="1.0"?> <CHANNEL LEVEL="2"     HREF="http://www.starpowder.com/planets.html">     <TITLE>Planets</TITLE>     <LOGO HREF="http://www.starpowder.com/icon.gif" STYLE="ICON"/>     <LOGO HREF="http://www.starpowder.com/image.gif" STYLE="IMAGE"/>     <LOGO HREF="http://www.starpowder.com/image-wide.gif" STYLE="IMAGE-WIDE"/>     <SCHEDULE TIMEZONE="-0800">         <INTERVALTIME DAY="5"/>         <EARLIESTTIME HOUR="3" TIMEZONE="-0800"/>         <LATESTTIME HOUR="5" TIMEZONE="-0800"/>     </SCHEDULE>     <ITEM HREF="http://www.starpowder.com/mercury.html">         <TITLE>All about Mercury</TITLE>         <ABSTRACT>             All planetary information for             Mercury, including orbital specifications.         </ABSTRACT>     </ITEM>     .     .     . </CHANNEL>

In this case, Internet Explorer will "Web crawl" two levels deep and retrieve all the documents when the main channel page changes. Note, however, that this is almost always wasteful, unless you really change your whole Web site when the main channel page changes.

Logging User Access

Using the <LOG> and <LOGTARGET> elements, which are children of the <CHANNEL> element, you can track which downloaded channel pages a user looks at offline. This can be useful if you have advertisements on those pages and need to know which pages were actually viewed. From the user's point of view, of course, it can also feel like another invasion of privacy.

To set up logging, you use the <LOG> element like this; you need the VALUE attribute (it's required), and the only valid value currently is "document:view":

<LOG VALUE="document:view"/>

The <LOGTARGET> element specifies where to send logging information. This information is sent in a way that can be handled by CGI scripts. This element has these attributes:

Attribute Description
HREF Specifies the URI to send logging information to.
METHOD Specifies the method used to send logging information; can be POST or PUT.
SCOPE Specifies what types of page viewing to count. It can be ALL, ONLINE, or OFFLINE.

The <LOGTARGET> element also has two possible child elements:

Attribute Description
<PURGETIME> Specifies the number of hours for which logging information is valid. Set the HOUR attribute to a number of hours.
<HTTP-EQUIV> Allows you to set key value pairs in the HTTP MIME header to send to the logging target.

For example, here's how I could enable offline logging in planets.cdf, sending updates to a CGI script named log.cgi:

<?xml version="1.0"?> <CHANNEL HREF="http://www.starpowder.com/planets.html">     <TITLE>Planets</TITLE>     <LOGO HREF="http://www.starpowder.com/icon.gif" STYLE="ICON"/>     <LOGO HREF="http://www.starpowder.com/image.gif" STYLE="IMAGE"/>     <LOGO HREF="http://www.starpowder.com/image-wide.gif" STYLE="IMAGE-WIDE"/>     <SCHEDULE TIMEZONE="-0800">         <INTERVALTIME DAY="5"/>         <EARLIESTTIME HOUR="3" TIMEZONE="-0800"/>         <LATESTTIME HOUR="5" TIMEZONE="-0800"/>     </SCHEDULE>     <LOG VALUE="document:view"/>     <LOGTARGET METHOD="POST" SCOPE="OFFLINE"         HREF="http://www.starpowder.com/cgi-bin/log.cgi">         <PURGETIME HOUR="24"/>         <HTTP-EQUIV NAME="ENCODING-TYPE" VALUE="text"/>     </LOGTARGET>     <ITEM HREF="http://www.starpowder.com/mercury.html">         <TITLE>All about Mercury</TITLE>         <ABSTRACT>             All planetary information for             Mercury, including orbital specifications.         </ABSTRACT>     </ITEM>     .     .     . </CHANNEL>

Setting a Channel Base URI

You can use the BASE attribute of the <CHANNEL> element to set a base URI for the channel, much as you can with the <BASE> element in HTML. The value that you assign to BASE must end with /. Here's an example; in this case, I'm setting a base URI for the channel, which then makes all other URIs relative to that base:

<?xml version="1.0"?> <CHANNEL BASE="http://www.starpowder.com/">     <TITLE>Planets</TITLE>     <LOGO HREF="icon.gif" STYLE="ICON"/>     <LOGO HREF="image.gif" STYLE="IMAGE"/>     <LOGO HREF="image-wide.gif" STYLE="IMAGE-WIDE"/>     <SCHEDULE TIMEZONE="-0800">         <INTERVALTIME DAY="5"/>         <EARLIESTTIME HOUR="3" TIMEZONE="-0800"/>         <LATESTTIME HOUR="5" TIMEZONE="-0800"/>     </SCHEDULE>     <ITEM HREF="mercury.html">         <TITLE>All about Mercury</TITLE>         <ABSTRACT>             All planetary information for             Mercury, including orbital specifications.         </ABSTRACT>     </ITEM>     .     .     . </CHANNEL>

Setting Last Modified Dates

The browser can check whether channel pages have been modified by reading the MIME header that comes with those pages and by checking the Last-Modified item in the header. In fact, the browser can request only the page's header, which means that it can check the last modified date without having to download the whole page.

On the other hand, this creates a lot of header requests. One way of changing that is the LASTMOD attribute of the <CHANNEL> and <ITEM> elements, which you set to a date and Greenwich Mean Time (GMT) like this: "2001-10-15T01:00:00". The browser can get the last modified time of a page from an element that uses the LASTMOD attribute in the CDF file, and download the document only if the cached version is dated earlier than the LASTMOD time. In this way, the browser can check LASTMOD times instead of having to query the server for MIME headers. Here's an example where I'm assigning a value to LASTMOD:

<?xml version="1.0"?> <CHANNEL HREF="http://www.starpowder.com/planets.html"     LASTMOD="2001-10-15T01:00:00">     <TITLE>Planets</TITLE>     <LOGO HREF="http://www.starpowder.com/icon.gif" STYLE="ICON"/>     <LOGO HREF="http://www.starpowder.com/image.gif" STYLE="IMAGE"/>     <LOGO HREF="http://www.starpowder.com/image-wide.gif" STYLE="IMAGE-WIDE"/>     <SCHEDULE TIMEZONE="-0800">         <INTERVALTIME DAY="5"/>         <EARLIESTTIME HOUR="3" TIMEZONE="-0800"/>         <LATESTTIME HOUR="5" TIMEZONE="-0800"/>     </SCHEDULE>     <ITEM HREF="mercury.html">         <TITLE>All about Mercury</TITLE>         <ABSTRACT>             All planetary information for             Mercury, including orbital specifications.         </ABSTRACT>     </ITEM>     .     .     . </CHANNEL>

Setting Channel Usage

With the <USAGE> element, you can set various ways of using channels beyond active channels. To determine the usage of a channel, you assign a value to the VALUE attribute from this list:

Value Description
Channel The default. The items in a channel appear in the browser's Favorites bar.
DesktopComponent Items displayed directly on the desktop in Active Desktop installations.
Email The parent element that will be emailed to the user when updated.
None Item will not appear in the Favorites bar.
Screensaver Item that is a screen saver.
SoftwareUpdate Item that is a software update.

We've already seen the default value, "Channel" at work. Using the "None" value just turns the item off as far as channels go. I'll take a look at the other possibilities here.

Updating Desktop Components

In Microsoft Active Desktop installations, desktop components are displayed directly on the Windows desktop and can be updated automatically. For example, say that some users want to keep tabs on all the major planets and want images continually updated on their desktops of those planets.

Here's how you might implement that, updating the image of Mercury every 20 minutes; note the child elements of <USAGE> in this case <WIDTH>, <HEIGHT>, <OPENAS>, and <CANRESIZE>:

<?xml version="1.0"?> <CHANNEL HREF="http://www.starpowder.com/planets.html">     <TITLE>         Planetary Images     </TITLE>     <ABSTRACT>         These are updated planetary images.     </ABSTRACT>     <ITEM         HREF="http://www.starpowder.com/mercury.gif">         <TITLE>Image of Mercury</TITLE>         <SCHEDULE TIMEZONE="-0800">             <INTERVALTIME MIN="20"/>             <EARLIESTTIME HOUR="0"/>             <LATESTTIME HOUR="23"/>         </SCHEDULE>          <USAGE VALUE="DesktopComponent">             <WIDTH VALUE="400"/>             <HEIGHT VALUE="400"/>             <OPENAS VALUE="Image"/>             <CANRESIZE VALUE="No"/>         </USAGE>     </ITEM> </CHANNEL>

Updating Through Email

You can also indicate how to handle email updates; in this case, you can set the usage to "Email", which means that the parent item will be sent to the user in email. For example, here's how I indicate that I want update.html sent to the user when updates occur:

<?xml version="1.0"?> <CHANNEL HREF="http://www.starpowder.com/planets.html">     <TITLE>Planets</TITLE>     <LOGO HREF="http://www.starpowder.com/icon.gif" STYLE="ICON"/>     <LOGO HREF="http://www.starpowder.com/image.gif" STYLE="IMAGE"/>     <LOGO HREF="http://www.starpowder.com/image-wide.gif" STYLE="IMAGE-WIDE"/>     <SCHEDULE TIMEZONE="-0800">         <INTERVALTIME DAY="5"/>         <EARLIESTTIME HOUR="3" TIMEZONE="-0800"/>         <LATESTTIME HOUR="5" TIMEZONE="-0800"/>     </SCHEDULE>     <ITEM HREF="update.html">         <USAGE VALUE="Email"/>     </ITEM>     <ITEM HREF="mercury.html">         <TITLE>All about Mercury</TITLE>         <ABSTRACT>             All planetary information for             Mercury, including orbital specifications.         </ABSTRACT>     </ITEM>     .     .     . </CHANNEL>

Updating Screen Savers

If you set the usage of an item to "Screensaver", that HTML page will be downloaded and used as the new screen saver. To use this option, the user must have selected the "Channel Screen Saver" as the current screen saver, as shown in Figure 18.9; if the user has not, Windows will ask whether to do so when the screen saver's CDF file is opened.

Figure 18.9. Selecting a channel screen saver.

graphics/18fig09.gif

Here's an example where I'm adding a screen saver (you can set only one per CDF file) to planets.cdf:

<?xml version="1.0"?> <CHANNEL HREF="http://www.starpowder.com/planets.html">     <TITLE>Planets</TITLE>     <LOGO HREF="http://www.starpowder.com/icon.gif" STYLE="ICON"/>     <LOGO HREF="http://www.starpowder.com/image.gif" STYLE="IMAGE"/>     <LOGO HREF="http://www.starpowder.com/image-wide.gif" STYLE="IMAGE-WIDE"/>     <SCHEDULE TIMEZONE="-0800">         <INTERVALTIME DAY="5"/>         <EARLIESTTIME HOUR="3" TIMEZONE="-0800"/>         <LATESTTIME HOUR="5" TIMEZONE="-0800"/>     </SCHEDULE>     <ITEM HREF="http://www.starpowder.com/planets.gif">         <USAGE VALUE="ScreenSaver"/>     </ITEM>     <ITEM HREF="mercury.html">         <TITLE>All about Mercury</TITLE>         <ABSTRACT>             All planetary information for             Mercury, including orbital specifications.         </ABSTRACT>     </ITEM>     .     .     . </CHANNEL>

Updating Software

You can also update software packages automatically using the <USAGE> element in CDF files and setting its VALUE attribute to "SoftwareUpdate". You also must indicate what you want to have happen, using Open Software Description (OSD) in a special element, <SOFTPKG>. You can learn more about OSD here:

  • http://msdn.microsoft.com/workshop/management/osd/osdfaq.asp. Microsoft's OSD FAQ

  • http://msdn.microsoft.com/workshop/delivery/osd/overview/osd.asp. An overview of OSD

Here's an example; in this case, I'll set up updating for a software package named StarGazerKing. The actual installation uses Cabinet (CAB) files of the type that the Microsoft Visual Studio products such as Visual Basic create. I'm listing three alternate CABs, one for each of three operating systems you can add a <SCHEDULE> element if you want the browser to check for updates regularly:

<?xml version="1.0"?> <CHANNEL HREF="http://www.starpowder.com/planets.html">     <TITLE>StarGazerKing Update</TITLE>     <ABSTRACT>         StarGazerKing now comes with a spellchecker!     </ABSTRACT>     <USAGE VALUE="SoftwareUpdate"/>     <SOFTPKG NAME="StarGazerKing"         AUTOINSTALL="No"         VERSION="2, 1, 0, 0"         STYLE="ActiveSetup">         <TITLE>StarGazerKing</TITLE>         <ABSTRACT>             StarGazerKing now comes with spellchecking,             and it'll increase your productivity greatly!         </ABSTRACT>         <IMPLEMENTATION>             <OS VALUE="win95" />             <CODEBASE HREF="http://www.starpowder.com/cabs/sgk95.cab">         </IMPLEMENTATION>         <IMPLEMENTATION>             <OS VALUE="winnt" />             <CODEBASE HREF="http://www.starpowder.com/cabs/sgknt.cab">         </IMPLEMENTATION>         <IMPLEMENTATION>             <OS VALUE="mac" />             <CODEBASE HREF="http://www.starpowder.com/cabs/sgkmac.cab">         </IMPLEMENTATION>     </SOFTPKG> </CHANNEL>

Windows will ask users whether they want the update to take place because I set AUTOINSTALL to "No"; you can set it to "Yes" to make the installation automatic, but that also has the potential of making users angry because they'll be installing new versions of software without their consent. I suggest that you avoid automatic installation. There are a great many more options here if you are interested, take a look at the software update material on the Microsoft CDF sites.

That completes our look at RDF and CDF, two popular XML applications. In the next chapter, I'll take a look at another XML application: VML.

CONTENTS


Inside XML
Real World XML (2nd Edition)
ISBN: 0735712867
EAN: 2147483647
Year: 2005
Pages: 23
Authors: Steve Holzner

Similar book on Amazon

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net