Section 5.4. Introducing RSS 1.0


5.4. Introducing RSS 1.0

Now that we're steeped in metadata and RDF syntax, it's time to move on to RSS 1.0. This standard, released in December 2000, brought two major changes to the RSS world: the reintroduction of RDF and with it an introduction of namespaces.

Nowadays, of course, both flavors of RSS have namespaced modules. But only RSS 1.0 is in RDF. Example 5-4 shows what it looks like.

Example 5-4. A sample RSS 1.0 document
<?xml version="1.0" encoding="utf-8"?>     <rdf:RDF  xmlns="http://purl.org/rss/1.0/"   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"    xmlns:dc="http://purl.org/dc/elements/1.1/"   xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"   xmlns:co="http://purl.org/rss/1.0/modules/company/"   xmlns:ti="http://purl.org/rss/1.0/modules/textinput/" >        <channel rdf:about="http://meerkat.oreillynet.com/?_fl=rss1.0">   <title>Meerkat</title>   <link>http://meerkat.oreillynet.com</link>   <description>Meerkat: An Open Wire Service</description>   <dc:publisher>The O'Reilly Network</dc:publisher>   <dc:creator>Rael Dornfest (mailto:rael@oreilly.com)</dc:creator>   <dc:rights>Copyright &#169; 2000 O'Reilly &amp; Associates, Inc.</dc:rights>   <dc:date>2000-01-01T12:00+00:00</dc:date>   <sy:updatePeriod>hourly</sy:updatePeriod>   <sy:updateFrequency>2</sy:updateFrequency>   <sy:updateBase>2000-01-01T12:00+00:00</sy:updateBase>       <image rdf:resource="http://meerkat.oreillynet.com/icons/meerkat-powered.jpg" />   <textinput rdf:resource="http://meerkat.oreillynet.com" />       <items>     <rdf:Seq>       <rdf:li rdf:resource="http://c.moreover.com/click/here.pl?r123" />     </rdf:Seq>   </items> </channel>     <image rdf:about="http://meerkat.oreillynet.com/icons/meerkat-powered.jpg">   <title>Meerkat Powered!</title>   <url>http://meerkat.oreillynet.com/icons/meerkat-powered.jpg</url>   <link>http://meerkat.oreillynet.com</link> </image>     <textinput rdf:about="http://meerkat.oreillynet.com">   <title>Search Meerkat</title>   <description>Search Meerkat's RSS Database...</description>   <name>s</name>   <link>http://meerkat.oreillynet.com/</link>   <ti:function>search</ti:function>   <ti:inputType>regex</ti:inputType> </textinput>     <item rdf:about="http://c.moreover.com/click/here.pl?r123">   <title>XML: A Disruptive Technology</title>   <link>http://c.moreover.com/click/here.pl?r123</link>   <dc:description>This the description of the article</dc:description>   <dc:publisher>The O'Reilly Network</dc:publisher>   <dc:creator>Simon St.Laurent (mailto:simonstl@simonstl.com)</dc:creator>   <dc:rights>Copyright &#169; 2000 O'Reilly &amp; Associates, Inc.</dc:rights>   <dc:subject>XML</dc:subject>   <co:name>XML.com</co:name>   <co:market>NASDAQ</co:market>   <co:symbol>XML</co:symbol> </item> </rdf:RDF>

5.4.1. Walking Through an RSS 1.0 Document

At first glance, RSS 1.0 can look very complicated indeed. It isn't really, and breaking an example into chunks can help a great deal, so let's do that.

Throughout this section, we'll also examine RDF in XML syntax in general. An RSS 1.0 document is also a valid RDF document (though the reverse isn't always true, and you must not forget that RDF has many different ways of being written).

Example 5-4 is a simple RSS 1.0 feed with one item, an image, and a text-input section. The first line includes the standard XML declaration, declaring the document's encoding to be UTF-8:

<?xml version="1.0" encoding="utf-8"?>

The root element (the first line) is also the place to declare the additional namespaces that are used in the document, telling the parser that you're also going to use the vocabularies represented by these certain URIs. The required line already declares the namespace for all the core elements of RSS 1.0the elements that appear without a colonand the namespace for RDF:

<rdf:RDF xmlns="http://purl.org/rss/1.0/"   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"    xmlns:dc="http://purl.org/dc/elements/1.1/"   xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"   xmlns:co="http://purl.org/rss/1.0/modules/company/"   xmlns:ti="http://purl.org/rss/1.0/modules/textinput/" >

Namespaces are represented by URIs. Nothing special needs to be at the namespace's URI (though by convention there is usually some documentation about the module);the only requirement is that the URI and the namespace are unique to each other. The syntax of a namespace declaration is simple and can be read aloud for greater understanding. For example, the line xmlns:dc="http://purl.org/dc/elements/1.1/ is read as follows: "the XML namespace dc is associated with the URI http://purl.org/dc/elements/1.1."

Every namespace used in the RSS 1.0 document must be declared in the root element. For documents with many namespaces, this element can look very untidy, but a judicious application of spaces and new lines can make it easier to read.

Now let's look at the channel element:

<channel rdf:about="http://meerkat.oreillynet.com/?_fl=rss1.0">   <title>Meerkat</title>   <link>http://meerkat.oreillynet.com</link>   <description>Meerkat: An Open Wire Service</description>   <dc:publisher>The O'Reilly Network</dc:publisher>   <dc:creator>Rael Dornfest (mailto:rael@oreilly.com)</dc:creator>   <dc:rights>Copyright &#169; 2000 O'Reilly &amp; Associates, Inc.</dc:rights>   <dc:date>2000-01-01T12:00+00:00</dc:date>   <sy:updatePeriod>hourly</sy:updatePeriod>   <sy:updateFrequency>2</sy:updateFrequency>   <sy:updateBase>2000-01-01T12:00+00:00</sy:updateBase>

In the first half of the channel element, you can see the main differences in structure between RSS 0.9x and RSS 1.0. First, every top-level element (channel, item, image, text input) has an rdf:about attribute. This denotes the URI of that resource in the scope of RDF.

Second, you can see subelements of the channel using namespaces. In this example, dc: and sy: (the Dublin Core and Syndication modules) are in use.

Next comes a major departure from RSS 0.9x. The image and textinput elements of RSS 1.0 aren't contained within the channel. Rather, channel contains a pointer to their objects, which are elsewhere in the RSS 1.0 document, at the same level as channel. The pointers are RDF notation, using the rdf:resource attribute:

<image rdf:resource="http://meerkat.oreillynet.com/icons/meerkat-powered.jpg" /> <textinput rdf:resource="http://meerkat.oreillynet.com" />

In the same way, within RSS 1.0 (unlike RSS 0.9x), channel doesn't contain any item elements. It does, however, contain an items element within which sits an RDF list of all the item elements that exist within the whole document. Again, these are simply pointers that provide the correct RDF descriptions:

  <items>     <rdf:Seq>       <rdf:li rdf:resource="http://c.moreover.com/click/here.pl?r123" />     </rdf:Seq>   </items>     </channel>

Note that the channel element is closed here. Unlike RSS 0.9x, in RSS 1.0, channel doesn't encompass the entire document. Once it has defined its own metadata and pointed to the items, image, and textinput objects, its job is done.

The image, textinput, and item elements are similar to the RSS 0.9x equivalents, differing only in that they declare the rdf:about attribute, as previously discussed, and allow for additional namespaced subelements from the optional modules:

<image rdf:about="http://meerkat.oreillynet.com/icons/meerkat-powered.jpg">   <title>Meerkat Powered!</title>   <url>http://meerkat.oreillynet.com/icons/meerkat-powered.jpg</url>   <link>http://meerkat.oreillynet.com</link> </image>     <textinput rdf:about="http://meerkat.oreillynet.com">   <title>Search Meerkat</title>   <description>Search Meerkat's RSS Database...</description>   <name>s</name>   <link>http://meerkat.oreillynet.com/</link>   <ti:function>search</ti:function>   <ti:inputType>regex</ti:inputType> </textinput>     <item rdf:about="http://c.moreover.com/click/here.pl?r123">   <title>XML: A Disruptive Technology</title>   <link>http://c.moreover.com/click/here.pl?r123</link>   <dc:description>This the description of the article</dc:description>   <dc:publisher>The O'Reilly Network</dc:publisher>   <dc:creator>Simon St.Laurent (mailto:simonstl@simonstl.com)</dc:creator>   <dc:rights>Copyright &#169; 2000 O'Reilly &amp; Associates, Inc.</dc:rights>   <dc:subject>XML</dc:subject>   <co:name>XML.com</co:name>   <co:market>NASDAQ</co:market>   <co:symbol>XML</co:symbol> </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