RSS


This style of distributing XML content is particularly common on news sites that distribute their headlines. Many use a standard format called RSS to do this. Example 2.4 is one example RSS file from Luke Tymowski's QubeQuorner on July 16, 2001. All you need to know is the URL where the constantly updated file is kept. All you need to send to the server is a request for this file.

Example 2.4 An RSS 0.91 Document
 <?xml version="1.0"?>  <!DOCTYPE rss PUBLIC           "-//Netscape Communications//DTD RSS 0.91//EN"           "http://my.netscape.com/publish/formats/rss-0.91.dtd" >   <rss version="0.91">     <channel>         <title>QubeQuorner</title>         <link>http://q.seeto.com</link>         <description>           A weblog for both the Sun Qube and Linux/BSD users         </description>         <language>en</language>         <managingEditor>           luke@seeto.com (Luke Tymowski)         </managingEditor>         <webMaster>luke@seeto.com (Luke Tymowski)</webMaster>         <item>            <title>Switching from Eudora/Mac to Pine</title>            <link>http://q.seeto.com/994897187</link>            <description>inessential.com: Switching from            Eudora/Mac to Pine "I recently switched from            Eudora/Mac, which I used for many years, to Pine            [on OS X]. Why the hell would I do a thing like that?            I had a few reasons."</description>            </item>         <item>            <title>Symmetric Cryptography in Perl</title>            <link>http://q.seeto.com/994895485</link>            <description>Perl.com: Symmetric Cryptography in Perl            "Having purchased the 0 cookie recipe from            Neiman-Marcus, Alice wants to send it to Bob, but keep            it away from Eve, who snoops on everyone's network            traffic from the cubicle down the hall. How can Perl            help her?"</description>            </item>         </channel> </rss> 

This is a pretty standard example of an RSS document. The root element is rss , which has a version attribute. Here the version is 0.91, the first version to achieve broad adoption, and still the version most prevalent on the Web today. The rss element contains a single channel element. The channel element begins with several child elements providing meta-information about the news site. Here title , link , description , language , managingEditor , and webMaster elements are used. Although not used here, the channel element can also contain language , rating , copyright , pubDate , lastBuildDate , skipHours , skipDay s, and several other elements. Finally the metadata is followed by multiple item elements, one for each story on the site. Most item s contain a title for the story, a link giving the URL to that particular story, and a description offering a brief plain-text abstract or summary of the story.

As you can see, RSS 0.91 is a very simple and straightforward format. It's easy to understand and easy to process. It's well- formed and valid XML. It is unfortunately not, however, legal RDF. Since the acronym RSS originally stood for "RDF Site Summary," this is viewed by some as a concern. (Today it doesn't really stand for anything.) The cause of the problem is that RSS achieved broad adoption before RDF was finished, and the syntax of RDF changed out from under RSS. Thus there is currently an effort to create a new version of RSS that is in fact legal RDF. Example 2.5 shows the same document from the QubeQuorner, but in RSS 1.0 instead of RSS 0.91.

Example 2.5 An RSS 1.0 Document
 <?xml version="1.0"?> <!DOCTYPE rdf:RDF [ <!ENTITY % HTMLlat1 PUBLIC  "-//W3C//ENTITIES Latin 1 for XHTML//EN"  "http://www.w3.org/TR/xhtml1/DTD/xhtml-lat1.ent"> %HTMLlat1; ]> <rdf:RDF  xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"  xmlns="http://purl.org/rss/1.0/"  xmlns:dc="http://purl.org/dc/elements/1.1/"  xmlns:ag="http://purl.org/rss/1.0/modules/aggregation/"  xmlns:admin="http://webns.net/mvcb/"  xmlns:syn="http://purl.org/rss/1.0/modules/syndication/" > <channel rdf:about="http://q.seeto.com/"> <title>QubeQuorner</title> <link>http://q.seeto.com/</link> <description>a weblog for the Qube community</description> <dc:rights>Copyright &#xA9; 2001 QubeQuorner.            All rights reserved.</dc:rights> <dc:publisher>Luke Tymowski (mailto:luke@seeto.com)</dc:publisher> <dc:language>en-us</dc:language> <dc:date>2001-06-09T10:30:21-05:00</dc:date> <syn:updatePeriod>hourly</syn:updatePeriod> <syn:updateFrequency>1</syn:updateFrequency> <syn:updateBase>1970-01-01T00:00:00-05:00</syn:updateBase> <admin:errorReportsTo rdf:resource="mailto:luke@seeto.com"/> <items> <rdf:Seq><rdf:li rdf:resource="http://q.seeto.com/994897187" /> <rdf:li rdf:resource="http://q.seeto.com/994895485" /> </rdf:Seq> </items> <textinput rdf:resource="http://q.seeto.com/" /> </channel>   <item rdf:about="http://q.seeto.com/994897187">     <title>Switching from Eudora/Mac to Pine</title>     <link>http://q.seeto.com/994897187</link>     <description>       inessential.com: Switching from Eudora/Mac to Pine       "I recently switched from Eudora/Mac, which I used for       many years, to Pine [on OS X]. Why the hell would I do a       thing like that? I had a few reasons."     </description>   </item>   <item rdf:about="http://q.seeto.com/994895485">     <title>Symmetric Cryptography in Perl</title>     <link>http://q.seeto.com/994895485</link>     <description>Perl.com: Symmetric Cryptography in Perl "Having      purchased the 0 cookie recipe from Neiman-Marcus, Alice      wants to send it to Bob, but keep it away from Eve, who      snoops on everyone's network traffic from the cubicle down      the hall. How can Perl help her?"</description>   </item>   <textinput rdf:about="http://q.seeto.com/">     <title>Search</title>     <description>       Search for a phrase that appeared in QubeQuorner     </description>     <name>body</name>     <link>http://q.seeto.com/search</link>   </textinput> </rdf:RDF> 

The most obvious difference is that RSS 0.9.1 is monolithic, whereas RSS 1.0 uses namespaces to mix together markup from RSS, RDF, the Dublin Core, and a couple more applications. It doesn't try to do it all. This requires somewhat more effort from the developer to handle; however, it does offer longer term extensibility and maintainability.

Not everyone agrees that RSS actually needs to be RDF, and consequently development has forked. There's a parallel effort to develop an RSS 0.9.2 that adds a few useful features to RSS 0.9.1, but otherwise attempts to maintain the simplicity of RSS 0.9.1.



Processing XML with Java. A Guide to SAX, DOM, JDOM, JAXP, and TrAX
Processing XML with Javaв„ў: A Guide to SAX, DOM, JDOM, JAXP, and TrAX
ISBN: 0201771861
EAN: 2147483647
Year: 2001
Pages: 191

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