Generating an RSS XML stylesheet using the RSS_sliml gem
require 'rss_sliml'
rsss = RssSliml.new
rsss.to_xslt
Output:
<?xml version='1.0' encoding='UTF-8'?>
<xsl:stylesheet xmlns:xsl='http://www.w3.org/1999/XSL/Transform' version='1.1'>
<xsl:output method='html' encoding='utf-8' indent='yes'/>
<xsl:template match='/'>
<html>
<head>
<title>
<xsl:value-of select='/rss/channel/title'/>
</title>
</head>
<xsl:apply-templates select='rss/channel'/>
</html>
</xsl:template>
<xsl:template match='channel'>
<body>
<div>
<xsl:apply-templates select='item'/>
</div>
</body>
</xsl:template>
<xsl:template match='item'>
<div>
<ul>
<li>
<a href='{link}'><xsl:value-of select="title"/></a>
<div>
<xsl:value-of select="description"/>
</div>
</li>
</ul>
</div>
</xsl:template>
</xsl:stylesheet>
puts rsss.to_sliml
div
ul
li
a {href: '{link}'} $title
div
$description
Note: A Sliml template can optionally be passed into initialization.
Resources
- rss_sliml https://rubygems.org/gems/rss_sliml
rss_sliml rss sliml xslt