XSLT

Purpose

Saxon-HE processor with stylesheet caching.

The open-source implementation of XSLT 3.0, XPath 2.0 and 3.1, and XQuery 3.1. This provides the “basic” conformance level of these languages; it also supports some optional features of the specifications such as serialization and support for XQuery modules.

Methods

Binding name: xslt


Method: String process( String id, String xslt, String xml )

Process the given xml with the supplied xslt, storing the compiled xslt in the cache with the supplied id. Results of the transformation are returned as a String.

Note

Subsequent calls to process() will search for and use the cached instance of the compiled XSLT giving much greater performance. The cache will expire entries after 10 minutes of inactivity.

Examples

def results = xslt.process("myTransform", resource.get('STYLESHEET'), resource.get('XmlIn'))
println results

STYLESHEET

<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
  <xsl:template match="/hello-world">
    <HTML>
      <HEAD>
        <TITLE></TITLE>
      </HEAD>
      <BODY>
        <H1>
          <xsl:value-of select="greeting"/>
        </H1>
        <xsl:apply-templates select="greeter"/>
      </BODY>
    </HTML>
  </xsl:template>
  <xsl:template match="greeter">
    <DIV>from <I><xsl:value-of select="."/></I></DIV>
  </xsl:template>
</xsl:stylesheet>
XmlIn

<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="hello.xsl"?>
<hello-world><greeter>An XSLT Programmer</greeter><greeting>Hello, World!</greeting></hello-world>