Transforming XML into RSS
file: gang2rss.xsl
1 2 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> 3 4 <xsl:output method="xml" encoding="iso-8859-1" indent="yes" /> 5 6 <xsl:template match="rss"> 7 8 <rss version="2.0"> 9 <channel> 10 <title>The Gang</title> 11 <link>http://newsgang.net/audio/</link> 12 <description>The Gang podcast</description> 13 14 <language>en</language> 15 16 <xsl:apply-templates select="item" /> 17 18 </channel> 19 </rss> 20 21 </xsl:template> 22 23 <xsl:template match="item"> 24 25 <item> 26 <title><xsl:value-of select="title"/></title> 27 <link>http://newsgang.net<xsl:value-of select="href"/></link> 28 <description><xsl:value-of select="date"/></description> 29 <enclosure>http://newsgang.net<xsl:value-of select="href_audio"/></enclosure> 30 </item> 31 32 </xsl:template> 33 34 </xsl:stylesheet>
To transform the xsl file from the command-line you would type:
xsltproc gang2rss.xsl thegang_rss.xml
output
1 2 <?xml version="1.0" encoding="iso-8859-1"?> 3 <rss version="2.0"> 4 <channel> 5 <title>The Gang</title> 6 <link>http://newsgang.net/audio/</link> 7 <description>The Gang podcast</description> 8 <language>en</language> 9 <item> 10 <title>TheGangXII-II</title> 11 <link>http://newsgang.net/gangitem/id=6501</link> 12 <description>Jan 25</description> 13 <enclosure>http://newsgang.net/gangitem/id=6501&from=audio</enclosure> 14 </item> 15 <item> 16 <title>TheGangXII-I</title> 17 <link>http://newsgang.net/gangitem/id=6499</link> 18 <description>Jan 25</description> 19 <enclosure>http://newsgang.net/gangitem/id=6499&from=audio</enclosure> 20 </item> 21 <item> 22 <title>NewsGangLive01.24.08</title> 23 <link>http://newsgang.net/gangitem/id=6445</link> 24 <description>Jan 24</description> 25 <enclosure>http://newsgang.net/gangitem/id=6445&from=audio</enclosure> 26 </item> 27 <item> 28 <title>NewsGangLiveII</title> 29 <link>http://newsgang.net/gangitem/id=6377</link> 30 <description>Jan 23</description> 31 <enclosure>http://newsgang.net/gangitem/id=6377&from=audio</enclosure> 32 </item> 33 </channel> 34 </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)