Posts

Showing posts with the label rss

XSL for XML with namespaces

This started off as a problem with writing a single XSL for RSS and ATOM feeds. To be fair, producing separate XSL files for RSS and ATOM feeds should not be a huge problem. Attempting to merge them is probably not trivial. Thankfully, writing a XSL file for RSS is pretty trivial. It uses regular XSL know-how. However, writing one for ATOM seemed very different! The reason is that the ATOM XML comes with namespaces. I've encountered these two namespaces in use in different feeds: <feed version="0.3" xmlns="http://purl.org/atom/ns#"> and <feed xmlns="http://www.w3.org/2005/Atom"> As such, a regular template match will not match the content of the document. <xsl:template match="feed"> I'll need to write the XSL such that both gets matched. In order to match the first feed, I'll need the template to be: <xsl:template match="{http://purl.org/atom/ns#}feed"> To shortcut this, you'll need to have a pref...