Hack 82 Create an RSS 1.0 Document

figs/beginner.gif figs/hack82.gif

Create an RSS 1.0 document using a template or with Java.

RSS 1.0 is a branch from RSS 0.91 that incorporates elements from the W3C's Resource Description Framework or RDF (http://www.w3.org/RDF/). Some folks didn't particularly like this branch to RDF because they saw it as too complex. Nevertheless, RSS 1.0 is now a popular format for RSS documents, running a close second to RSS 0.91, according to http://www.syndic8.com/stats.php?Section=rss#RSSVersion.

Following is a minimal example of an RSS 1.0 document, available in the file archive as wyeast.rss and at http://www.wyeast.net/wyeast.rss:

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


 <channel rdf:about="http://www.wyeast.net/wyeast.rss">

  <title>Wy'east Communications</title>


  <description>Wy'east Communications is an XML 




    <rdf:li rdf:resource="http://www.wyeast.net/wyeast.html"/>




 <item rdf:about="http://www.wyeast.net/wyeast.html">

  <title>Legend of Wy'east</title>


  <description>The Native American story behind the name 




The rdf:RDF element from the RDF namespace (http://www.w3.org/1999/02/22-rdf-syntax-ns#) is the document element. This element must have exactly one channel child and one or more item children (these elements are in the default namespace, http://purl.org/rss/1.0). The rdf:about attribute on channel, from the RDF namespace, identifies the feed with a URI. Following channel are these elements:


A descriptive title for this channel.


A URI for the channel.


A description of the channel.


Contains the RDF elements Seq and li. The resource attribute on rdf:li contains a URI that identifies an item used later in the document.

Like channel, the sole item element holds title, link, and description elements that describe the news item. There can be virtually unlimited item element children after channel here. The rdf:about attribute on item must be unique and should match the content of link.

Two other possible children of channel are image and textinput, which link by means of rdf:resource attributes to other image and textinput elements, optionally used in the document as children of rdf:RDF (i.e., you can have one without the other). The image element links a graphic to the channel and must contain the trio title, link, and url; the textinput element contains a script or form that relates to the site and contains title, link, name, and description elements.

The document wyeast.rss was generated by a Java program, Rss1.java, available in the file archive. This program was written using the XML Object Model or XOM (http://cafeconleche.org/XOM/), an easy-to-use XML API written by Elliotte Rusty Harold.

In order to work, Rss1.java needs Xerces and XOM JARs in the classpath at compile time, and the XOM JAR in the classpath at runtime. You can get xercesImpl.jar from http://www.apache.org/dist/xml/xerces-j/ and the XOM JAR from the XOM web site. This program can be adapted to work with any of the RSS or Atom vocabularies.

6.4.1 See Also

  • To use a Perl program to generate an RSS 1.0 document; http://search.cpan.org/~kellan/XML-RSS-1.02/lib/RSS.pm