Creating an RSS XML stylesheet using RexleBuilder

require 'rexle'
require 'rexle-builder'

xml = RexleBuilder.new
raw_a = xml.xsl_stylesheet(xmlns_xsl: \
                 "http://www.w3.org/1999/XSL/Transform", version: "1.1") do
  xml.xsl_output(method: "html", encoding: "utf-8", indent: "yes")

  xml.xsl_template(match: '/') do
    xml.html do
      xml.head do
        xml.title do
          xml.xsl_value_of(select: '/rss/channel/title')
        end
      end
      
      xml.xsl_apply_templates(select: 'rss/channel')
    end
  end      

  xml.xsl_template(match: 'channel') do
    xml.body do
      xml.div do
        xml.xsl_apply_templates(select: 'item')
      end
    end
  end

  xml.xsl_template(match: 'item') do
    xml.div do
      xml.ul do
        xml.li do
          xml.a href: '{link}'
            xml.xsl_value_of select: 'title'
          xml.div do
            xml.xsl_value_of(select: 'description')
          end
        end
      end
    end
  end

end

xml2 = Rexle.new(raw_a).xml(pretty: true).gsub('xsl_apply_templates',\
    'xsl:apply-templates').gsub('xsl_value_of','xsl:value-of').\
    gsub('xsl_template','xsl:template').\
    gsub('xmlns_xsl','xmlns:xsl').gsub('xsl_for_each','xsl:for-each').\
    gsub('xsl_','xsl:')

puts xml2

File.write '/tmp/rss.xsl', xml2

When I executed the statement xsltproc /tmp/rss.xsl rss.xml I observed the following:

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>My weather feed for Lochend, Edinburgh</title>
</head>
<body><div>
<div><ul><li>
<a href="http://www.jamesrobertson.eu/weather/2015/nov/02/#1009"></a>10am: 8°C, Mostly Cloudy<div>10am: 8°C, Mostly Cloudy</div>
</li></ul></div>
<div><ul><li>
<a href="http://www.jamesrobertson.eu/weather/2015/nov/02/#0949"></a>9am: 8°C, Mostly Cloudy<div>9am: 8°C, Mostly Cloudy</div>
</li></ul></div>
<div><ul><li>
<a href="http://www.jamesrobertson.eu/weather/2015/nov/02/#0939"></a>9am: 7°C, Mostly Cloudy<div>9am: 7°C, Mostly Cloudy</div>
</li></ul></div>
</div></body>
</html>