Introducing the Polyrex-XSLT gem
Usage
require 'polyrex-xslt'
schema = 'entries/entry[title]'
xslt_schema = 'tree/item[@title:title, @qty:qty]'
pxsl = PolyrexXSLT.new schema: schema, xslt_schema: xslt_schema
puts pxsl.to_xslt
Output
<?xml version='1.0' encoding='UTF-8'?> <xsl:stylesheet xmlns:xsl='http://www.w3.org/1999/XSL/Transform' version='1.0'> <xsl:output method='xml' indent='yes' omit-xml-declaration='yes'/> <xsl:template match='tree'> <entries> <summary/> <records> <xsl:apply-templates select='item'/> </records> </entries> </xsl:template> <xsl:template match='item'> <entry> <summary> <xsl:element name='title'> <xsl:value-of select='@title'/> </xsl:element> <xsl:element name='qty'> <xsl:value-of select='@qty'/> </xsl:element> </summary> <records/> </entry> </xsl:template> </xsl:stylesheet>
Resources
- polyrex-xslt https://rubygems.org/gems/polyrex-xslt
xslt polyrex_xslt gem polyrex