WARNING: This server provides a static reference view of the NetKernel documentation. Links to dynamic content do not work. For the best experience we recommend you install NetKernel and view the documentation in the live system .

Endpoint
Name:xslt
Description:The active:xslt service performs an XSLT transform of an XML document
Id:apache.XSLTRuntime
Category:accessor
Identifier Syntax

xslt is an accessor using Active URI syntax with the following base identifiers:

Base
active:xslt
active:xsltc

and the following arguments: (for more details on argument passing details see here)

ArgumentRulesTypingDescription
operand
Mandatory
Representation (DOM, SAX, HDS, Readable Binary Stream)XML resource to be transformed
operator
Mandatory
Representation (XSL Stylesheet)XSL Stylesheet or Transform specification
varargs [param] Any quantityRepresentation (java.lang.Object)Optional parameters provided to the stylesheet runtime
Request Verbs

The following verb is supported:

Verb
SOURCE
Response

The following response representations can be returned for SOURCE requests:

SOURCE Representations
DOMBinary Streamjava.lang.String

This accessor throws no documented exceptions.

Import Requirements

To use xslt accessor you must import the module urn:org:netkernel:xml:core:

<import>
  <uri>urn:org:netkernel:xml:core</uri>
</import>

When a request with the SOURCE verb is issued to active:xslt the XSLT transforms or stylesheet specified in the required operator argument is used to transform the XML resource specified in the required operand argument. By default, the response representation returned is an XML document.

Stylesheet Parameters

The XSLT accessor accepts any number of optional arguments.

Each argument is then supplied as a named parameter to the stylesheet and must be defined in the stylesheet as an external parameter using declarations and 'must have the same name as the argument.

By default a parameter will be assumed to be an XML Document. However the following example illustrates that POJO parameters can be passed to the transformer. A POJO parameter must be declared to the stylesheet using the nk:class attribute containing the full package name of the POJO. The types of POJO that may be passed is transform engine specific. For example, the Xalan transformer accepts String, Integer, Float and org.w3c.dom.Node.

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:nk="http://netkernel.org" version="1.0">
  <xsl:output method="xml" />
  <xsl:param name="param1" />
  <xsl:param name="param2" nk:class="java.lang.String" />
  <xsl:param name="param3" nk:class="java.lang.Integer" />
  <xsl:param name="param4" nk:class="java.lang.Float" />
  <xsl:template match="/hello">
    <result>
      <xsl:copy-of select="." />
      <param>
        <xsl:value-of select="$param1" />
      </param>
      <param2>
        <xsl:copy-of select="$param2" />
      </param2>
      <param3>
        <xsl:copy-of select="$param3" />
      </param3>
      <param4>
        <xsl:copy-of select="$param4" />
      </param4>
    </result>
  </xsl:template>
</xsl:stylesheet>

Compiled Transformer

If active:'xsltc' is used as the base then the transform will be compiled and executed as bytecode. Performance is considerably higher at the expense of compilation latency on first use and possible inconsistent coverage of the XSLT specification.