1.14 web.xml -- XSLT Transform

#
1.14 `web.xml` -- XSLT Transform

The `web.xml` module currently only provides one function, `transform()`, used to apply an XSL Stylesheet to an XML document.

`transform`( | input, stylesheet, output)

  input
    The path to the XML file
  stylesheet
    The path to the stylesheet file
  output
    The file where the output should be written

For Example:

file-web-xml.xml

    <source>

    <title>XSL</title>
    <author>John Smith</author>

    </source>

file-web-xml.xsl

    <xsl:stylesheet version = '1.0'
         xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>
    <xsl:template match="/">
         <h1>
              <xsl:value-of select="//title"/>
         </h1>
         <h2>
              <xsl:value-of select="//author"/>
         </h2>
    </xsl:template>
    </xsl:stylesheet>

And the code to transform it:

command-web-xml.py

    #!/usr/bin/env python

    import sys; sys.path.append('../../../') # show python where the web modules are
    import web.xml
    web.xml.transform("file-web-xml.xml","file-web-xml.xsl","xml.html")

This creates the output file test.html:

    <?xml version="1.0"?>
    <h1>XSL</h1><h2>John Smith</h2>