5.5. The Specification in Detail
This section is based on the RSS 1.0 Specification, Version 1.3.4, dated May 30, 2001. The full document is available at http://purl.org/rss/1.0/spec.
5.5.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 5-5 and Example 5-6 show this difference in their basic structures.
Example 5-5. The basic structure of RSS 0.9x
<rss> <channel> <image/> <textinput/> <item/> <item/> <item/> </channel> </rss>
Example 5-6. 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.
5.5.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 use are declared in the root element.
5.5.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 </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 itselfi.e., the URI.
188.8.131.52 Required subelements of channel
channel can contain many subelements. The additional modules, detailed in Chapter 6, define about 30 optional additions to these core subelements:
The following elements are required only if the feed contains the objects to which they refer. RSS 1.0 doesn't 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.
5.5.4. <image rdf:resource=""> (a Subelement of rdf:RDF)
Although optional, image is used quite a bit. 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 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 we will discuss in Chapter 6. The mandatory subelements are:
5.5.5. <textinput rdf:about=""> (a Subelement of rdf:RDF)
This element, like its RSS 2.0 counterpart, provides a way to describe 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:
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:
5.5.6. <item rdf:about=""> (a Subelement of rdf:RDF)
The item subelement is where the real work gets done. Like its RSS 2.0 namesake, the item subelement contains the details of each URL 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 thingsbasically anything that can be represented by a URL, even if it isn't an ordinary page.
Because of this capability, the item subelement is most affected by the use of optional modules. We'll deal with those in Chapter 6; for now, here are its core subelements:
5.5.7. The Simplest Possible RSS 1.0 Feed
Whatever you do, when you produce an RSS 1.0 feed, it has to contain at least all of the fields in Example 5-7.
Example 5-7. The simplest possible RSS 1.0 feed
<?xml version="1.0" encoding="UTF-8"?> <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"> <channel rdf:about="http://example.org/index.html"> <title>The Simplest Feed</title> <link>http://example.org/index.html</link> <description>The Simplest Possible RSS 1.0 Feed</description> <items> <rdf:Seq> <rdf:li rdf:resource="http://example.org/example_entry" /> </rdf:Seq> </items> </channel> <item rdf:about="http://example.org/example_entry"> <title></title> <link>http://example.org/example_entry</link> </item> </rdf:RDF>
Section 5.5. The Specification in Detail