Section 5.5. The Specification in Detail


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.

5.5.3.1 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:


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 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.


<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 seemingly complicated. 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>

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:


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 is normally to the page the feed represents, so it is usually identical to the link subelement of channel.

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:

The field is typically used as a search box or subscription formamong 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.

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:


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).

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>



    Developing Feeds with RSS and Atom
    Developing Feeds with Rss and Atom
    ISBN: 0596008813
    EAN: 2147483647
    Year: 2003
    Pages: 118

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