Project

xml_to_xsl

0.0
No commit activity in last 3 years
No release in over 3 years
Creates XSLT from XML
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies
 Project Readme

Introducing the xml_to_xsl gem

require 'xml_to_xsl'

xml = "<doc>
  <klass name='SimpleNumber'>
    <def name='initialize' scope='private'></def>
    <def name='add' scope='public'></def>
    <def name='multiply' scope='public'></def>
    <def name='divide' scope='private'></def>
    <def name='square' scope='protected'></def>
  </klass>
</doc>"

puts XMLToXSL.new(xml).to_xsl

output:

<xsl:stylesheet xmlns:xsl='http://www.w3.org/1999/XSL/Transform' version='1.0'>

  <xsl:template match='doc'>

    <xsl:element name='doc'>
  
      <xsl:apply-templates select='klass' />
    </xsl:element>

  </xsl:template>

  <xsl:template match='klass'>

    <xsl:element name='klass'>
      <xsl:attribute name='name'>
        <xsl:value-of select='@name'/>
      </xsl:attribute>
      <xsl:apply-templates select='def' />
    </xsl:element>

  </xsl:template>

  <xsl:template match='def'>

    <xsl:element name='def'>
      <xsl:attribute name='name'>
        <xsl:value-of select='@name'/>
      </xsl:attribute>
      <xsl:attribute name='scope'>
        <xsl:value-of select='@scope'/>
      </xsl:attribute>
      <xsl:value-of select='.' />
    </xsl:element>

  </xsl:template>

</xsl:stylesheet>

Resources

xmltoxsl gem xslt xml xml_to_xsl