Changes

Jump to navigation Jump to search
127 bytes removed ,  16:17, 26 May 2012
no edit summary
This [[Module Library|XQuery Module]] contains functions and variables to perform XSLT transformations. By default, this module uses Java’s XSLT 1.0 Xalan implementation to transform documents. XSLT 2.0 is used instead if Version 9.x of the [http://www.saxonica.com/ Saxon XSLT Processor] (<code>{{Code|saxon9he.jar</code>}}, <code>{{Code|saxon9pe.jar</code>}}, <code>{{Code|saxon9ee.jar</code>}}) is found in the classpath. A custom transformer can be specified by overwriting the system property <code>{{Code|javax.xml.transform.TransformerFactory</code>}}, as shown in the following Java example:
<pre class="brush:java">
=Conventions=
All functions in this module are assigned to the <code>{{Code|http://basex.org/modules/xslt</code> }} namespace, which is statically bound to the <code>{{Code|xslt</code> }} prefix.<br/>All errors are assigned to the <code>{{Code|http://basex.org/errors</code> }} namespace, which is statically bound to the <code>{{Code|bxerr</code> }} prefix.
=Variables=
|-
| width='90' | '''Signatures'''
|<code><b>{{Code|'''$xslt:processor</b> ''' as xs:string</code>}}<br />
|-
| '''Summary'''
|-
| width='90' | '''Signatures'''
|<code><b>{{Code|'''$xslt:version</b> ''' as xs:string</code>}}<br />
|-
| '''Summary'''
|-
| width='90' | '''Signatures'''
|<code><b>{{Func|xslt:transform</b>(|$input as item(), $stylesheet as item()) as |node()</code>}}<br /><code><b>{{Func|xslt:transform</b>(|$input as item(), $stylesheet as item(), $params as item()) as |node()</code>}}
|-
| '''Summary'''
|Transforms the document specified by <code>{{Code|$input</code>}}, using the XSLT template specified by <code>{{Code|$stylesheet</code>}}, and returns the result as <code>{{Code|node()</code> }} instance. <code>{{Code|$input</code> }} and <code>{{Code|$stylesheet</code> }} can be specified as<br />* <code>{{Code|xs:string</code>}}, containing the path to the document,* <code>{{Code|xs:string</code>}}, containing the document in its string representation, or* <code>{{Code|node()</code>}}, containing the document itself.The <code>{{Code|$params</code> }} argument can be used to bind variables to a stylesheet. It can be specified as* <code>{{Code|element(xslt:parameters)</code>}}: <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>{{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 Module|map structure]]: all parameters can be directly represented as key/value pairs:<br /><code>{{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.
|}
<div>
<xsl:for-each select='books/book'>
<b>'''<xsl:apply-templates select='title'/></b>''': <xsl:value-of select='author'/><br/>
</xsl:for-each>
</div>
<body>
<div>
<b>'''XSLT Programmer´s Reference</b>''': Michael H. Kay<br> • <b>'''XSLT</b>''': Doug Tidwell<br>
</div>
</body>
Bureaucrats, editor, reviewer, Administrators
13,554

edits

Navigation menu