IntroductionXSLT 1.0 and XSLT 2.0 are languages for transforming XML documents into other XML documents. Orbeon Forms uses XSLT extensively to process XML documents. Orbeon Forms ships with Saxon 9.1, which supports XSLT 2.0 and XPath 2.0 in addition to XSLT 1.0 and XPath 1.0. Additionally, Orbeon Forms can use any Java API for XML Processing (JAXP) compliant transformer. Inputs and outputs
Processor namesThere are three generic processors: a generic JAXP (TrAX) processor, and two specialized XSLT processors (one for XSLT 1.0 and one for XSLT 2.0), which provides additional functionality related to XSLT:
You usually don't use directly the generic processors. Instead, you use concrete processors that leverage the generic processors:
The most commonly used processor is UsageTransformer inputThe This input specifies a specific concrete subclass of <p:processor name="oxf:trax"><p:input name="transformer"><config><class>com.mytrans.TransformerFactoryImpl</class></config></p:input><p:input name="config"><mytrans>...</mytrans></p:input><p:input name="data"><document>...</document></p:input><p:output name="data" id="mytrans"/></p:processor>
Attributes inputThe
This is an example of configuration supported by Saxon: <attributes xmlns:xs="http://www.w3.org/2001/XMLSchema"><attribute as="xs:boolean" name="http://saxon.sf.net/feature/allow-external-functions" value="false"/><attribute as="xs:boolean" name="http://saxon.sf.net/feature/linenumbering" value="false"/><attribute as="xs:integer" name="http://saxon.sf.net/feature/recoveryPolicy" value="2"/></attributes>
The Config inputThe <xsl:stylesheet version="1.0"><xsl:template match="/"><new-root><xsl:value-of select="/root/a"/><xsl:value-of select="/root/b"/></new-root></xsl:template></xsl:stylesheet>
Data inputThe <root><a>a</a><b>b</b></root>
Data outputThe <new-root>ab</new-root>
User-defined inputsXSLT transformers support reading optional user-defined inputs through the XSLT and XPath <p:processor name="oxf:xslt"><p:input name="config"><address-book xsl:version="2.0"><!-- Access external XML document --><xsl:variable name="document-1" select="doc('file:/document-1.xml')"/><!-- Access oxf:xslt processor user-defined input --><xsl:variable name="document-2" select="doc('input:my-input')"/><!-- ... --></address-book></p:input><!-- Standard oxf:xslt processor input --><p:input name="data" href="#some-id"/><!-- Declare oxf:xslt processor user-defined input --><p:input name="my-input" href="#some-other-id"/><!-- Standard oxf:xslt processor output --><p:output name="data" id="address-book"/></p:processor>
In this example, the XPath expression The second variable, Note
The user-defined input referenced from <p:pipeline><!-- Pipeline input --><p:input name="my-pipeline-input" type="input"/><!-- XSLT transformation --><p:processor name="oxf:xslt"><p:input name="config"><address-book xsl:version="2.0"><!-- Access oxf:xslt processor user-defined input --><xsl:variable name="document-2" select="doc('input:my-input')"/><!-- ... --></address-book></p:input><!-- Standard oxf:xslt processor input --><p:input name="data" href="#some-id"/><!-- Connect the oxf:xslt processor input to the pipeline input --><p:input name="my-input" href="#my-pipeline-input"/><!-- Standard oxf:xslt processor output --><p:output name="data" id="address-book"/></p:processor><!-- ... --></p:pipeline>
User-defined outputs[SINCE: 2011-03-30]
With
<xsl:result-document> , you can produce output documents in addition to the main output document produced on the data output of the processor.
The special output: URL scheme allows addressing processor outputs by name.You can also address
file: and oxf: URLs.NOTE:
<xsl:result-document> is only enabled with oxf:unsafe-* processors.XML Pipeline Language (XPL) XPath function library[SINCE 2011-10-10] When:
then functions from the pipeline function library are available in the http://www.orbeon.com/oxf/pipeline namespace (which means that you usually prefix them with p: ).Passing parameters to XSLT stylesheetsXSLT supports XPL does not have a particular mechanism to set such stylesheet parameters, but a simple workaround allows setting them. Assume you have a stylesheet with a <xsl:transform><xsl:param name="start" select="'a1'"/><!-- ... --></xsl:transform>
To set the <p:processor name="oxf:xslt"><p:input name="data" href="#stylesheet-input"/><p:input name="config"><xsl:stylesheet version="2.0"><xsl:import href="my-stylesheet.xsl"/><xsl:param name="start" select="'a2'"/></xsl:stylesheet></p:input><p:output name="data" id="stylesheet-output"/></p:processor>
The rules of XSLT's Also note that while XPL does not have a native mechanism to pass XSLT parameters, it has a mechanism to pass extra documents available through the |