Note: CogDogBlog has a new WordPress powered home at http://cogdogblog.com/. All entries from this version have been moved there, so as a guide dog service try finding this article in its new home by title search.
XSLT + RSS: Why Pretty for only some browsers or is some implementations?
I've been mildly curious about some of the new attempts at making RSS feeds more human readable at first click- rather than seeing ugly XML code, these "new" feed displays use CSS (Style sheets) and some sort of magical transform method called XSLT -- basically it means if you click a link that points to an XML file, it has some nicer formatting applied.
I want to believe.
The problem is that I think a lot of folks doing this are not widely testing, because while it has pretty formatting on a PC with MSIE, or perhaps Mozilla/Firefox on Mac or Windows, it works. I've seen less then stellar appearance on Safari, which I had assumed (wrongly) was one of the more standards compliant browsers. Is it a limit of Safari? Am I doomed to switching browsers?
But then I peeked at a feed from a Blogger site, on Safari, and it had the feed + CSS + XSLT cooking. So what have they done right?
For example, here is a new feed shared by Stephen Downes, a transfoemed display of the RSS feed he created for the IT form list, http://www.downes.ca/itforum.xml:
http://www.downes.ca/itforum.xml viewed in Safari
Ugly, no transform. Unreadable by humans
But it looks okay (I guess) in Mozilla:
http://www.downes.ca/itforum.xml viewed in Mozilla
Better, it has formatting
At this point, I really was chalking it up to a Safari quirk. But then, after Stephen mentioned a new blog from Albert IP, Random Walk in E-Learning, I decided to tack on the magic code to get the feed (Blogger provides Atom feeds, but sadly, stupidly, does not build the links in the standard templates- but the feeds are there, if you just tack on an
atom.xml to the URL, or in this case, http://elearningrandomwalk.blogspot.com/atom.xml:
http://elearningrandomwalk.blogspot.com/atom.xml viewed in Safari
So is it that Blogger has a better transform? Does it have something to do with Atom being the feed format from Blogger? I dunno, this is all new to me, but I am curious to dig deeper.
blogged August 13, 2004 10:40 PM
:: category [
Feed for comments on this entry
Feed for all CDB comments
OK, first, repeat after me: nothing works in Safari.
Sure, this isn't strictly true, of course. Some things work. But I canot count how many times I've heard the phrase "that doesn't work in Safari."
So what's happening here? Why does the Atom feed work and the OLDaily feed not?
The OLDaily feed begins with an XML file, like the Atom feed. But the OLDaily feed includes an XSL file, while the Atom feed includes a CSS file.
The difference between the two is that the XSL used by OLDaily will read the data elements and, depending on what it finds, create some output. While the CSS used by the Atom feed will treat the XML as though it were pseudo-HTML and simply apply formatting to it.
The method used by the Atom file is described here: http://starvingartist.stanleysy.com/archives/2004/july/safarithemedrssandatomfeedswithcss/
Exactly the same thing can be done with an RSS feed. Here is an example: http://home.no.net/ldah/kommentarer.xml
So why did I use XSL rather than CSS?
Now here's the kicker: Safari doesn't support XSL. Not at all (at least, not to my knowledge, though I have searched the web to confirm this). So when Safari encounters an RSS file, it treats it as though it were HTML, resulting in the bad output you experienced.
So why don't I simply use the CSS method instead of the XSL method?
Mostly, because I have long ago given up on supporting Safari's odd quicks (such as not supporting an entire standard). If you are using Safari, switch. Use Firefox, which (mostly) supports XSL.
More information: http://interglacial.com/~sburke/stuff/pretty_rss.html