How to extend RSS 2.0Posted by Dave Winer, 11/22/04 at 8:59:58 AM.
The roadmap section of the RSS 2.0 spec says it is "for all practical purposes, frozen," which led some people to say that it's not possible to extend the format, but nothing could be further from the truth. In fact, the spec is not only extensible, it tells you how to do it -- "in modules, using namespaces."
So the purpose of this tutorial is to show you, using an example, how to create a RSS 2.0 module, in a namespace. Like almost everything about RSS it's really simple!
Example #1, Adding an ISSN to your feed
ISSN stands for International Standard Serial Number.
According to the Library of Congress, "serials are print or non-print publications issued in parts, usually bearing issue numbers and/or dates. A serial is expected to continue indefinitely. Serials include magazines, newspapers, annuals (such as reports, yearbooks, and directories), journals, memoirs, proceedings, transactions of societies, and monographic series."
Many magazines and newspapers have ISSNs, as do some books, and so do some weblogs. The ISSN for Scripting News is 1533-8185.
ISSN's are pefect examples of metadata -- data about your data, and if you have one for your publication, wouldn't you like to include it in your RSS feed? Here's a step-by-step checklist for doing exactly that.
1. First, check the RSS 2.0 spec to see if it provides for ISSN's. Sometimes there's a core element in the spec that covers the data you want to add. If so, you're done -- just use the core element, it saves you work, and it's more likely to work with feed readers and aggregators. In general, it's best if there's just one way of doing things, it keeps everything as simple as possible.
2. Okay, I checked, and there is no provision for an ISSN in the RSS 2.0 spec. So the next thing to do is to write a spec that explains how my new element will work. I put the spec on its own web page, this is important as you will see in step 5.
About the spec. I always follow the same form when doing a module spec, so that once someone learns how to read one of my specs, they find the second one easier to understand. The design of the spec is not something I consider proprietary, so you're welcome to use it as a template for your specs. Also, the address of the spec is important. Try to keep it as short and memorable as you can, and put it in a place that's likely to continue to exist for years to come.
3. Create an example. As part of writing a namespace spec, I always create an example of the use of the namespace. This is important for a couple of reasons. First, in doing so I often spot problems, and this is a good time to spot them, because they're so easy to fix at this stage; and second, an example aids in understanding -- a picture is worth a thousand words, and the picture of a namespace is an example of its use in the real world.
4. Ask for feedback. Find a few people whose opinions matter to you, and ask them to review both the concept and specification of your namespace. Listen to their feedback, and use your judgement. Maybe you want to go back to step 2, and edit the spec. Or maybe to step 1 to see if there isn't already a core element that does what you want to do.
5. You're ready to go, it doesn't have to be a big deal. Support the namespace in your feeds. Put the namespace declaration at the top of the feed, as an attribute of the rss element. Follow the example in the issn module. If you have questions, post them as a comment here and we'll try to get you the answers as soon as we can. It may seem that there's not enough "glue" connecting all the parts together, but remember the web is loosely joined. The spec is just for human beings, the software doesn't need it. Basically all the applications that use your feed assume you know what you're doing and ignore things they don't care about. Even though the core of RSS is frozen, RSS is itself a liberal environment, you don't need anyone's permission to extend RSS 2.0. It's really just this easy.
What if you want to change an existing element. Easy, suppose the element you want to change is called zupzenkabing. Create a namespace with a single element. In the spec for the new element say "It's just like zupzenkabing, except..." or something like that. The rule is: you can't change an existing element, but you can create a new one that's just like an existing one, with documented differences.
Creative Commons module.