tags:

views:

464

answers:

3

Back in about 2006, I wrote a nice XSLT that transformed my RSS feeds into custom HTML. That way if a user clicked from a browser it would display as a simple page rather than a bunch of junk XML. If that same URL was used in a feed reader it was handled properly and everything was slick.

Now days, most browsers (IE, Firefox, Safari, Opera) seem to grab hold of the styles and won't let go. And Chrome just plain ignores the stylesheet transformation.

Given that it has been several years, am I simply forgetting some detail? Didn't it used to just be this easy?

<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="/atom2html.xslt"?>
<feed xmlns="http://www.w3.org/2005/Atom"&gt;
    <!-- ... -->
</feed>

Anyone know if there is a way to override those browsers with very specific ideas of feed styling? And is there any way to get something nice out of Chrome?

+1  A: 

I'm not aware of a way to fool IE & FF & Safari's automatic display of RSS/Atom feeds, but in Chrome the XSLT is correctly applied via the xml-stylesheet processing instruction; here is an example from the Randonneur Group pool at flickr.

bolk
I'm not seeing any Atom feed links on that example Flickr page. Are you sure that is the right URL?
McKAMEY
Ops, a pasted the wrong URL in the link.This is the page with the copy of the feed:http://linusmat.com/files/stackoverflow/atom.xmland this is the xsl applied:http://linusmat.com/files/stackoverflow/atom.xsl
bolk
+1 your example gave me a great starting place to determine why mine wasn't working. Thanks!
McKAMEY
+2  A: 

Chrome appears to only apply the XSLT processing instruction if the Content-Type for the feed response is set to XML, not Atom.

This displays XSLT in Chrome:

Content-Type: application/xml

This does not display any styling (which is technically the more correct type):

Content-Type: application/atom+xml
McKAMEY
+1  A: 

It is now default behaviour for most browser to apply their own XSLT to any Atom/RSS feed they come across, very annoying. A feed is identified through the application/atom+xml mime type for Atom and application/rss+xml for RSS

You used to be able to circumvent this by filling the first 512 bytes of the feed with crud in the form of a comment. This would throw off the feed sniffing of the browser and allow you to apply your own XSL Stylesheet. This has worked for years for me but with IE8 this behaviour has gone out of the window and the 512 bytes comment doesn't work anymore. I have now switched over to server side processing but I still lament this decision from browser makes.

Meint