6.2 The Specification in Detail

This section is based on the RSS 1.0 Specification, Version 1.3.4, dated 30 May 2001. The full document is available at http://purl.org/rss/1.0/spec.

6.2.1 The Basic Structure

As we've seen, RSS 1.0's structure differs from the earlier versions of RSS by bringing the item , image, and textinput elements to the same level as channel. Examples Example 6-2 and Example 6-3 show this difference in their basic structures.

Example 6-2. The basic structure of RSS 0.9x
<rss>
<channel>
   <image/>
   <textinput/>
   <item/>
   <item/>
   <item/>
</channel>
</rss>
Example 6-3. The basic structure of RSS 1.0
<rdf>
  <channel/>
  <image/>
  <textinput/>
  <item/>
  <item/>
  <item/>
</rdf>

This difference both results from, and necessitates, the use of RDF notation to define the relationships between the elements.

6.2.2 The Root Element

The root element of an RSS 1.0 document is always built upon this line:

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

Any additional namespace declarations are inserted within this line. When designing your feed, and again after creating it, it is worth checking that all the namespaces you have used have been declared in the root element.

6.2.3 <channel rdf:about=""> (a Subelement of rdf:RDF)

The next level begins with the required channel element. This element must look like this:

<channel rdf:about="URI THAT IDENTIFIES THE CHANNEL">
   
subelements here
   
</content>

The contents of the rdf:about attribute must represent the feed itself. The specification states that this may be either the URL of the feed itself or the URL of the site it represents. Common usage seems to favor the URL of the feed itself ? i.e., the URI.

6.2.3.1 Required subelements of channel

channel can contain many subelements. The additional modules, detailed in Chapter 7, define about 30 optional additions to these core subelements:

title

The title of the feed, with a suggested maximum of 40 characters

description

A summary of the feed, with a suggested maximum of 400 characters

link

The URL of the site the feed represents

The following elements are required only if the feed contains the objects to which they refer. RSS 1.0 does not require an image, text input, or even any items to be present. However, the feed will be very dull indeed without at least one of these elements:

<image rdf:resource= "URI OF THE IMAGE" />

This line creates the RDF relationship between the channel and any <image> within the RSS 1.0 feed. The URI within the rdf:resource must therefore be the same as the URI within the rdf:about element (which we'll discuss later) contained within the image element (i.e., the URL of the image file itself).

<textinput rdf:resource= " URI OF THE TEXT INPUT" />

This line creates the RDF relationship between the channel and any <textinput> element within the feed. The URI within the rdf:resource must, again, be the same as the URI within the rdf:about element of the textinput element later in the feed. This URL should be the URL to which a text-input submission will be directed.

items'

The items element is tremendously important and pleasingly simple-yet-complicated-looking. It defines the RDF relationship between the channel and any item found within the RSS 1.0 document. The URIs should be the same as the rdf:resource attribute of each of the items later in the document, so they should be identical to the value of the link subelement of the item element, if possible. For example:

<items>
<rdf:Seq>
<rdf:li resource="URI OF ITEM 1" />
<rdf:li resource="URI OF ITEM 2" />
...
</rdf:Seq>
</items>

6.2.4 <image rdf:resource=""> (a Subelement of rdf:RDF)

Unlike RSS 0.9x, there is no requirement for an image to be associated with an RSS 1.0 feed. This is because RSS 1.0 is not restricted to uses that involve plain-and-simple parsing into HTML. Mandating an image would be superfluous on these occasions.

Nevertheless, image is still used a great deal. According to the specification, "this image should be of a format supported by the majority of web browsers. While the later 0.91 specification allowed for a width of 1-144 and height of 1-400, convention (and the 0.9 specification) dictate 88 x 31."

This element takes the rdf:resource attribute. This attribute should be the URL of the image file, and it should be mirrored within the image subelement of channel.

The element also takes three mandatory subelements, in addition to the optional subelements available through the modules that we will discuss in Chapter 7. The mandatory subelements are:

title

The alternative text (alt attribute) associated with the channel's image tag when rendered as HTML. Text should be no more than 40 characters.

url

The URL of the image file. This also appears within the rdf:resource attribute and is mirrored within the <image> subelement of the <channel>.

link

The URL to which the image file will link when the feed is rendered in HTML. This link usually is to the page the feed represents, so it is usually identical to the link subelement of channel.

6.2.5 <textinput rdf:about=""> (a Subelement of rdf:RDF)

This element, like its RSS 0.9x counterpart, provides a method of describing a form of input for delivering data to a URL that can deal with an HTTP GET request (a CGI script, for example). It's entirely optional, however, as the specification states:

The field is typically used as a search box or subscription form?among others. While this is of some use when RSS documents are rendered as channels and accompanied by human readable title and description, the ambiguity in automatic determination of meaning of this overloaded element renders it otherwise not particularly useful. RSS 1.0 therefore suggests either deprecation or augmentation with some form of resource discovery of this element in future versions while maintaining it for backward compatibility with RSS 0.9.

Nevertheless, it is still used. It takes an rdf:about attribute, which should point to the URL contained within its own link subelement, and requires four mandatory subelements:

title

The label for the Submit button. It has a maximum of 40 characters.

description

Text to explain what the textinput actually does. It has a maximum of 100 characters.

name

The name of the text object that is passed to the CGI script. It has a maximum of 500 characters.

link

The URL of the CGI script. It has a maximum of 500 characters.

6.2.6 <item rdf:about=""> (a Subelement of rdf:RDF)

The item subelement is where the real work gets done. Like its RSS 0.9x namesake, the item subelement contains the details of each of the URLs listed within the feed, along with metadata, description, and so on. Unlike RSS 0.9x, however, RSS 1.0's item can point to many different things ? basically anything that can be represented by a URL, even if it is not an ordinary page.

Because of this capability, the item subelement is the one most affected by the use of optional modules. We'll deal with those in Chapter 7, so for now we'll look at its own core subelements:

title

The title of the object. The maximum length is 100 characters.

link

The URL of the object. The maximum is 500 characters.

description

A synopsis of the object. This element is optional. The maximum length is 500 characters and it must be plain text only (no HTML).