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

Image

We can optionally associate a little image (usually 88x33 pixels) with our channel to be used in a My.Netscape-style newsbox rendering. A title element provides text for the image's alt attribute, a link element specifies where the image should hyperlink to, and the url element is the location of the image file itself. We'll use values similar to the channel definition above and add the URL of our imaginary logo.



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

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

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

</rdf:RDF>

Item(s)

We finally get to the meat (or tofu) of our RSS channel -- the items meant for syndication. There's not much room here for detail -- just a simple title and link. While we're allowed up to 15 items (1 at a minimum), we'll just add a couple.

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

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

  <image>
    <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>
    <title>Pecan Plenty</title>
    <link>http://www.pie-r-squared.com/pies/pecan.html</link>
  </item>

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

</rdf:RDF>

Textinput

Finally we arrive at the textinput element, affording a method for submitting form data to an arbitrary URL -- a script handling the GET method. While I'm not a big fan of the textinput element, we'll throw it in as a searchbox for laughs. Title and description are self-explanatory; link is the URL of the receiving script, and name is the variable to which anything entered into the box is assigned.

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

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

  <image>
    <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>
    <title>Pecan Plenty</title>
    <link>http://www.pie-r-squared.com/pies/pecan.html</link>
  </item>

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

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

So entering "chocolate" into the above-specified searchbox would result in an HTTP GET of http://www.pie-r-squared.com/search.pl?keyword=chocolate

Onward and upward to 1.0

While getting from our RSS 0.9 compliant document to RSS 1.0 takes only three simple mechanical changes, it opens up a whole new dimension of RSS extensibility and rich metadata relationships which we'll get to in a bit. Let's do the the easy mechanical pieces first. ...

As I mentioned at the beginning of this tutorial, the proposed RSS 1.0 builds on the foundation of RSS 0.9. It's just a 0.9 core with a little "syntactic sugar" mixed in for extensibility's sake.

"Syntactic sugar?" While RSS 0.9 had fledgling hooks for extensibility in its rdf:RDF root element and rudimentary support for namespaces, a spot more syntax is in order for RDF-enabled software to grok (read: understand) the structure of an RSS document. Parsers, not being as smart as you or I, don't know the significance of an item's <link> element, for example, and must be explicitly told: "The <link>'s the URL of the item we're talking about."

"I don't know a thing about RDF." No worries! The RDF markup is a simple mechanical transformation and doesn't require any particular understanding of RDF principles or serialization. That's not to say I don't encourage you to look into RDF, just that it's not necessary. Tim Bray provides a wonderful layperson's guide to RDF and Metadata, and it's a quick read if you have a sec.

"Why should I care about RDF support?" RDF will allow the computers that currently throw information at our feet at an alarming rate to instead work with us to make sense of it all and point us at the bits and pieces we are seeking. Some folks are working very hard to make this happen; with just a few simple additions, you can aid in this effort with no skin off your nose.

New default namespace

RSS 1.0 has its very own namespace, distinct from that of 0.9. We'll change the root rdf:RDF element's default namespace declaration to reflect this difference. (I've left off the rest of the document for brevity.)

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

...

</rdf:RDF>

What's it all rdf:about?

Each resource (channel, image, item(s), textinput) we describe must have an associated URI to specify canonically what it is we're describing. This is accomplished in RDF by giving it an about attribute -- as in "we're talking about this URI."

  • Since the <channel> element is talking about the RSS feed itself, we'll use the RSS document's URL.
  • The <image> element describes a particular URL-retrievable image, so we'll use the image's <url>.
  • Each <item> is a short description of something URL-retrievable (story, discussion thread, job listing, whatever), so we'll use the value of the item's <link> element.
  • In the case of <textinput>, we're talking about the <link> URL to which the GET is sent.

This leaves us with:

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

Pages: 1, 2, 3

Next Pagearrow





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