RSS 1.0 XSLT style sheet
If you don't know what RSS is, go here.
As you all know, when you click on a RSS feed link you will usually see the source XML file which holds it.
I was not happy because users who don't know what RSS feeds are will have no idea what's the purpose of the link. It would be nice if we could display the feed like a normal page.
I searched the web for a solution and I found out that it is possible to do just that using CSS or XSLT style sheets. But the style sheets I found were ugly or incomplete. So I decided to roll my own.
Surprisingly, XSLT
(a functional programming language for processing XML
data) was very easy to learn
(using the excellent Microsoft
documentation).
Most of the style sheet was done in a couple of hours.
Now let's see that RSS feed again, this time using my style sheet.
Usage
All you have to do is to download the style sheet and add the highlighted line at the head of your RSS feed file, after the <?xml?> declaration.
<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="rss10.xsl"?>
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
xmlns:admin="http://webns.net/mvcb/"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:cc="http://web.resource.org/cc/"
xmlns="http://purl.org/rss/1.0/">
<channel rdf:about="http://business2.blogs.com/business2blog/rss.xml">
That's the only difference between the two RSS feeds from above.
A nasty problem
Some RSS feed authors put HTML code in their items using CDATA. For the data to be displayed as intended, the XSLT processor has to unescape it. To do that the style sheet uses the disable-output-escaping attribute of the xsl:value-of instruction. Internet Explorer supports that attribute, but Mozilla and Firefox don't. A major Mozilla developer said that their browser will never do that.
Another problem that embedded HTML code brings is that if you forget to close a tag, the effect will spill to all the following items. See in the following real feed how the author forgot to close the <b> tag in the 3rd news item and all the following items are bolded. The error is repeated in the 14th item. You have to view the link with Internet Explorer. Like I said, Mozilla based browsers can't unescape the HTML code and will display it literally.
Download
Licensed under Creative Commons Attribution-ShareAlike 1.0.