Transforming XML into RSS
file: gang2rss.xsl
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output method="xml" encoding="iso-8859-1" indent="yes" /> <xsl:template match="rss"> <rss version="2.0"> <channel> <title>The Gang</title> <link>http://newsgang.net/audio/</link> <description>The Gang podcast</description> <language>en</language> <xsl:apply-templates select="item" /> </channel> </rss> </xsl:template> <xsl:template match="item"> <item> <title><xsl:value-of select="title"/></title> <link>http://newsgang.net<xsl:value-of select="href"/></link> <description><xsl:value-of select="date"/></description> <enclosure>http://newsgang.net<xsl:value-of select="href_audio"/></enclosure> </item> </xsl:template> </xsl:stylesheet>
To transform the xsl file from the command-line you would type:
xsltproc gang2rss.xsl thegang_rss.xml
output
<?xml version="1.0" encoding="iso-8859-1"?> <rss version="2.0"> <channel> <title>The Gang</title> <link>http://newsgang.net/audio/</link> <description>The Gang podcast</description> <language>en</language> <item> <title>TheGangXII-II</title> <link>http://newsgang.net/gangitem/id=6501</link> <description>Jan 25</description> <enclosure>http://newsgang.net/gangitem/id=6501&from=audio</enclosure> </item> <item> <title>TheGangXII-I</title> <link>http://newsgang.net/gangitem/id=6499</link> <description>Jan 25</description> <enclosure>http://newsgang.net/gangitem/id=6499&from=audio</enclosure> </item> <item> <title>NewsGangLive01.24.08</title> <link>http://newsgang.net/gangitem/id=6445</link> <description>Jan 24</description> <enclosure>http://newsgang.net/gangitem/id=6445&from=audio</enclosure> </item> <item> <title>NewsGangLiveII</title> <link>http://newsgang.net/gangitem/id=6377</link> <description>Jan 23</description> <enclosure>http://newsgang.net/gangitem/id=6377&from=audio</enclosure> </item> </channel> </rss>
Note: The enclosure url in this example does not reference the media file directly.
see also: http://en.wikipedia.org/wiki/RSS_(file_format)