views:

266

answers:

3

Using the category tag in RSS 2.0:

<category domain="http://mysite.example.com/tags"&gt;
    Science and Technology
</category>

How would I provide an additional URL to the page that shows all of the items in that category?

Since the spec doesn't appear cover this, would it be safe to invent a new attribute in my own namespace, like this:

<category domain="http://mysite.example.com/tags"
    myns:category-url="http://mysite.example.com/tags/scitech/"&gt;
    Science and Technology
</category>

Then at the top of the document:

<rss version="2.0" xmlns:myns="http://mysite.example.com/namespace/"&gt;

Is it OK to extend RSS in this way? Are any aggregators or implementations out there in the wild likely to break? Or is there an existing mechanism for linking to a category page that I should be using instead?

I'm interested in seeing how this would be done in Atom as well, but I need a solution for RSS 2.0.

+1  A: 

Yes, it should be perfectly safe to extend with a namespace - that is, after all, written explicitly in the spec at http://cyber.law.harvard.edu/rss/rss.html#extendingRss

It says "RSS 2.0 adds that capability, following a simple rule. A RSS feed may contain elements not described on this page, only if those elements are defined in a namespace." - but I'm adding my own namespaced attributes to an existing RSS element, so it's not clear if that's encouraged or not.
Simon Willison
+1  A: 

As you notice in the comment, it just says "A RSS feed may contain elements not described on this page, only if those elements are defined in a namespace.", but says nothing about new attributes, so I'd think that it is at least against the spirit of the spec to do so.

My understanding is that whatever is described in that page ought be considered frozen, with the exception of the ability to add namespaced elements.

Thus, i think that the one way to add what you need is to add a new element which has to have a content matching a category and an attribute holding the URL to the page that shows all of the items in that category:

<rss version="2.0" xmlns:myns="http://mysite.example.com/namespace/"&gt;
<category domain="http://mysite.example.com/tags"&gt;
    Science and Technology
</category>
<myns:category-url url="http://mysite.example.com/tags/scitech/"&gt;
    Science and Technology
</myns:category-url>

It's not pretty but it may work

LucaM
http://validator.w3.org/feed/docs/warning/UseOfExtensionAttr.html - it turns out the RSS Advisory Board ruled that adding your own namespaced attributes to existing elements is OK (as you pointed out the spec is vague here), but their recommendations were never merged in to the official spec for weird political reasons.
Simon Willison
Using the domain attribute feels wrong, because it's meant to provide an overall namespace for your entire category scheme - using it like that would indicate you have an entirely separate taxonomy scheme for every one of your tags.
Simon Willison
yep you're right here, i edited to remove the suggestion to use "the domain attribute of the category"
LucaM
A: 

http://validator.w3.org/feed/docs/warning/UseOfExtensionAttr.html

The RSS 2.0 spec is unclear as to whether you can add your own namespaced attributes to existing RSS elements. The RSS Advisory Board ruled that you can, but RSS politics meant their recommendations were never added to the official spec.

I'm still not sure what the best way of specifying "this category has this URL on the web" is, in RSS or Atom.

Simon Willison