O'Reilly NetworkO'Reilly.com
BooksAll ArticlesSafari BookshelfO'Reilly GearFree NewslettersSearch
RSS DevCenter Tech Jobs | Forum

O'Reilly Network RSS DevCenter


TOPICS

Web Design and Development
Classification
Community
Getting Started
ICE
OCS
RDF
RSS
ScriptingNews
Weblogs












Writing RSS 1.0
Pages: 1, 2, 3

Pulling it all together

Now the last thing to do to make your RSS document RDF happy is to tie together the various elements to the RSS channel itself.



"But aren't they tied together by virtue of being in the same RSS document?" Good question! While everything's syndicated/published in one document, one can't assume it'll all stay together as it travels the Net. Aggregators decouple items from their parent channels, stirring them in various combinations to cook up new RSS feeds for resyndication, incorporation into a Website, commentary, etc. RDFers are really gathering data ("stuff said about a particular URI") and merging them into large data structures for the purposes of poking and prodding to extract some meaningful relationships.

What I like to call the channel's "table of contents" allows for this decoupling and munging while retaining some memory of an RSS item's parentage. The idea is similar to referencing sources of quotes you've used in your term paper; that [14] after the quote serves to preserve the association between the words you quoted and the source thereof.

Let's start with the optional elements, image and textinput; this step is only necessary for the optional element(s) you do use. We simply copy each element's opening tag, replace the rdf:about with rdf:resource, make it an empty element by adding a / just before the closing angle-bracket, and paste it inside the <channel> element. A couple of copies, edits, and pastes later:

<?xml version="1.0" encoding="utf-8"?>
<rdf:RDF 
  xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
  xmlns="http://purl.org/rss/1.0/"
>

  <channel rdf:about="http:///www.pie-r-squared.com/rss.rdf">
    <title>Pie-R-Squared</title>
    <description>
      Download a delicious pie from Pie-R-Squared!
    </description>
    <link>http://www.pie-r-squared.com</link>

    <image rdf:resource="http:///www.pie-r-squared.com/images/logo88x33.gif" />
    <textinput rdf:resource="http://www.pie-r-squared.com/search.pl" />

  </channel>

  <image rdf:about="http:///www.pie-r-squared.com/images/logo88x33.gif">
    <title>Pie-R-Squared du Jour</title>
    <url>http://www.pie-r-squared.com/images/logo88x33.gif</url>
    <link>http://www.pie-r-squared.com</link>
  </image>

  <item rdf:about="http://www.pie-r-squared.com/pies/pecan.html">
    <title>Pecan Plenty</title>
    <link>http://www.pie-r-squared.com/pies/pecan.html</link>
  </item>

  <item rdf:about="http://www.pie-r-squared.com/pies/key_lime.html">
    <title>Key Lime</title>
    <link>http://www.pie-r-squared.com/pies/key_lime.html</link>
  </item>

  <textinput rdf:about="http://www.pie-r-squared.com/search.pl">
    <title>Search Pie-R-Squared</title>
    <description>Search our pie catalog...</description>
    <name>keyword</name>
    <link>http://www.pie-r-squared.com/search.pl</link>
  </textinput>

</rdf:RDF>

The items piece is only marginallly more complicated if you've ever used HTML's Order Lists: <ol> <li>something</li> ... </ol>

We create a new element called items which will hold our list of, well..., items. Since this will be an ordered list, we'll also wrap them in RDF's concept of a sequence, rdf:Seq. We then do precisely the same thing for each item that we did for image and textinput, except that we replace "item" with "li" (read: list item) and place these items in our preferred order inside our sequence list.

<?xml version="1.0" encoding="utf-8"?>
<rdf:RDF 
  xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
  xmlns="http://purl.org/rss/1.0/"
>

  <channel rdf:about="http:///www.pie-r-squared.com/rss.rdf">
    <title>Pie-R-Squared</title>
    <description>
      Download a delicious pie from Pie-R-Squared!
    </description>
    <link>http://www.pie-r-squared.com</link>

    <image rdf:resource="http:///www.pie-r-squared.com/images/logo88x33.gif" />
    <textinput rdf:resource="http://www.pie-r-squared.com/search.pl" />

    <items>
      <rdf:Seq>
        <li rdf:resource="http://www.pie-r-squared.com/pies/pecan.html" />
        <li rdf:resource="http://www.pie-r-squared.com/pies/key_lime.html" />
      </rdf:Seq>
    </items>

  </channel>

  <image rdf:about="http:///www.pie-r-squared.com/images/logo88x33.gif">
    <title>Pie-R-Squared du Jour</title>
    <url>http://www.pie-r-squared.com/images/logo88x33.gif</url>
    <link>http://www.pie-r-squared.com</link>
  </image>

  <item rdf:about="http://www.pie-r-squared.com/pies/pecan.html">
    <title>Pecan Plenty</title>
    <link>http://www.pie-r-squared.com/pies/pecan.html</link>
  </item>

  <item rdf:about="http://www.pie-r-squared.com/pies/key_lime.html">
    <title>Key Lime</title>
    <link>http://www.pie-r-squared.com/pies/key_lime.html</link>
  </item>

  <textinput rdf:about="http://www.pie-r-squared.com/search.pl">
    <title>Search Pie-R-Squared</title>
    <description>Search our pie catalog...</description>
    <name>keyword</name>
    <link>http://www.pie-r-squared.com/search.pl</link>
  </textinput>

</rdf:RDF>

That's all, folks!

And we're done! Now, that wasn't painful, was it? If you have any questions or recommendations as to how to make this tutorial even easier, please feel free to drop me a line. If you'd like to participate in the further development and fine-tuning of RSS 1.0, point your browser at the RSS-DEV Working Group mailing list and dive on in!

Conversion without being a convert

Want 1.0-compliance without becoming a convert? Then one of these Web-based RSS conversion tools just may be for you, my friend.

  • RSS2RDF
    R.V. Guha's lightning-fast RSS2RDF takes the URL of an RSS 0.9 or 0.91 file as an argument and returns an RSS 1.0 version thereof. Check out this live example using the RSS 0.9 document we created in the first part of this tutorial. RSS2RDF is also available for download as a Linux binary or MPL'd C source.
  • rss_converter
    Enjoy the copy-n-paste-n-copy ease of Jonathan Eisenzopf's form-based RSS converter. It slices, it dices, and it certainly does RSS -- from and to 0.9, 0.91, and 1.0. Simply paste in your RSS document, choose an output format and click "Convert." Jonathan's converter uses his popular XML::RSS Perl module.

For more RSS 1.0-compliant tools, libraries, XSLT stylesheets, code snippets, and more, be sure to visit the RSS-DEV tool shed.

Resources

For many more resources, visit the Resources section of the RSS 1.0 Specification proposal.

Suggestions, bug reports, and other feedback

We welcome any constructive criticism you might offer. Please post your suggestions, bug reports, praise, and other feedback to the O'Reilly Network RSS Forum.

Rael Dornfest is Founder and CEO of Portland, Oregon-based Values of n. Rael leads the Values of n charge with passion, unearthly creativity, and a repertoire of puns and jokes — some of which are actually good. Prior to founding Values of n, he was O'Reilly's Chief Technical Officer, program chair for the O'Reilly Emerging Technology Conference (which he continues to chair), series editor of the bestselling Hacks book series, and instigator of O'Reilly's Rough Cuts early access program. He built Meerkat, the first web-based feed aggregator, was champion and co-author of the RSS 1.0 specification, and has written and contributed to six O'Reilly books. Rael's programmatic pride and joy is the nimble, open source blogging application Blosxom, the principles of which you'll find in the Values of n philosophy and embodied in Stikkit: Little yellow notes that think.


Discuss this article in the O'Reilly Network RSS Forum.

Return to the O'Reilly RSS DevCenter.





Sponsored by:

Get Red Hat training and certification.

Contact UsMedia KitPrivacy PolicyPress NewsJobs @ O'Reilly
Copyright © 2000-2006 O’Reilly Media, Inc. All Rights Reserved.
All trademarks and registered trademarks appearing on the O'Reilly Network are the property of their respective owners.
For problems or assistance with this site, email