Changes

Jump to navigation Jump to search
74 bytes added ,  17:08, 19 November 2011
no edit summary
This module contains [[Querying#Functions|XQuery functions]] and variables to perform XSLT transformations. All functions are preceded by the <code>xslt:</code> prefix, which is linked to the <code>http://www.basex.org/modules/xslt</code> namespace.
By default, this module uses the internal Java’s XSLT 1.0 Xalan implementation of Java to transform documents. XSLT 2.0 is used instead if Version 9.x of the [http://www.saxonica.com/ Saxon XSLT Processor] (<code>saxon9he.jar</code>, <code>saxon9pe.jar</code>, <code>saxon9ee.jar</code>) is found in the classpath.A custom transformer can be specified by overwriting the system property <code>javax.xml.transform.TransformerFactory</code>, as shown in the following Java example:
A [[XSLT Module <pre class="brush:java">System.setProperty(Snapshot"javax.xml.transform.TransformerFactory", "org.custom.xslt.TransformerFactoryImpl")|preview page]] describes the features of the [http;Context ctx = new Context();String result = new XQuery("xslt://filestransform('...', '...')").execute(ctx);...basexctx.org/releases/latestclose();</ latest stable snapshot].pre>
==$xslt:processor==
|-
| valign='top' | '''Summary'''
|This variable contains the name of the applied XSLT processor , or the path to a custom implementation (currently: <code>"Java</code> ", "Saxon EE", "Saxon PE", or <code> "Saxon</code>HE").<br />
|}
|-
| valign='top' | '''Summary'''
|This variable contains the supported XSLT version (currently: <code>"1.0</code> " or <code>"2.0</code>"). "Unknown" is returned if a custom implementation was chosen.<br />
|}
|-
| valign='top' | '''Summary'''
|Transforms the document specified by <code>$input</code>, using the XSLT template specified by <code>$stylesheet</code>, and returns the result as <code>node()</code> instance. If Saxon is found in the Java classpath, <code>XSLT 2.0</code> is applied; otherwise, Java’s internal <code>XSLT 1.0</code> Xalan implementation is used. <code>$input</code> and <code>$stylesheet</code> can be specified as<br />
* <code>xs:string</code>, containing the path to the document,
* <code>xs:string</code>, containing the document in its string representation, or
The <code>$params</code> argument can be used to bind variables to a stylesheet. It can be specified as
* <code>element(xslt:parameters)</code>: <code>&lt;xslt:parameters/&gt;</code> must be used as root element, and the parameters are specified as child nodes, with the element name representing the key and the text node representing the value:<br /><code>&lt;xslt:parameters&gt;<br/>&nbsp;&nbsp;&lt;xslt:key1&gt;value1&lt;/xslt:key1&gt;<br/>&nbsp;&nbsp;...<br/>&lt;/xslt:parameters&gt;</code>
* [[Map_FunctionsMap Module|map structure]]: all parameters can be directly represented as key/value pairs:<br /><code>map { "key1" := "value1", ... </code>}<br/>This variant is more compact, and it facilitates the binding of arbitrary data types. Note that only strings are supported when using Saxon (XSLT 2.0). Next, the map structures are not part of the XQuery language yet, as the standardization is still in progress.|-| valign='top' | '''Errors'''|<b>[[XQuery Errors#BaseX Errors|BASX0011]]</b> is raised if the specified parameter is unknown.
|}
Bureaucrats, editor, reviewer, Administrators
13,554

edits

Navigation menu