blob: 244bce064a2c3599775443550cff4986953440cb [file] [log] [blame]
<?xml version="1.0" standalone="no"?>
<!DOCTYPE s1 SYSTEM "../../style/dtd/document.dtd">
<!--
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
-->
<s1 title="Extensions library">
<ul>
<li><link anchor="intro">Introduction</link></li>
<li><link anchor="exslt">Beta support for EXSLT extensions</link></li>
<li><link anchor="xalanns">Xalan namespace</link></li>
<li><link anchor="nodeset">nodeset</link></li>
<li><link anchor="intersection">intersection</link></li>
<li><link anchor="difference">difference</link></li>
<li><link anchor="distinct">distinct</link></li>
<li><link anchor="evaluate">evaluate</link></li>
<li><link anchor="hassamenodes">hasSameNodes</link></li>
</ul>
<anchor name="intro"/>
<s2 title= "Introduction">
<p>Extension functions provide a powerful mechanism
for extending and simplifying what you can do with an XLST processor like
Xalan. With input and contributions from the XML open-source developer community, we are working on placing the most useful
extensions in an extensions library distributed with &xslt4c;. If you have ideas and/or contributions you would like to make,
please email us at the <human-resource-ref idref="xalandev"/>.</p>
</s2>
<anchor name="exslt"/>
<s2 title="EXSLT extensions">
<p>&xslt4c; supports the <jump href="http://exslt.org/">EXSLT</jump> initiative to provide a set of
standard extension functions to XSLT users. &xslt4c; includes beta implementations for
functions in four of the EXSLT namespaces (some are calls to extension already in the Xalan namespace).</p>
<p>The source files for the implementations are in the XalanEXSLT subdirectory of the source tree. See</p>
<ul>
<li><jump href="apiDocs/XalanEXSLTCommonImpl_8hpp.html">XalanEXSLTCommonImpl</jump></li>
<li><jump href="apiDocs/XalanEXSLTMathImpl_8hpp.html">XalanEXSLTMathImpl</jump></li>
<li><jump href="apiDocs/XalanEXSLTSetImpl_8hpp.html">XalanEXSLTSetImpl</jump></li>
<li><jump href="apiDocs/XalanEXSLTStringImpl_8hpp.html">XalanEXSLTStringImpl</jump></li>
<li><jump href="apiDocs/XalanEXSLTDynamicImpl_8hpp.html">XalanEXSLTDynamicImpl</jump></li>
<li><jump href="apiDocs/XalanEXSLTDateTimeImpl_8hpp.html">XalanEXSLTDateTimeImpl</jump></li>
</ul>
<p>For the function specifications, see:</p>
<ul>
<li><jump href="http://www.exslt.org/exsl/exsl.html">EXSLT common functions</jump></li>
<li><jump href="http://www.exslt.org/math/math.html">EXSLT math functions</jump></li>
<li><jump href="http://www.exslt.org/set/set.html">EXSLT set functions</jump></li>
<li><jump href="http://www.exslt.org/str/str.html">EXSLT string functions</jump></li>
<li><jump href="http://www.exslt.org/dyn/dyn.html">EXSLT dynamic functions</jump></li>
<li><jump href="http://www.exslt.org/date/date.html">EXSLT date-time functions</jump></li>
</ul>
<p>Anyone who would like to participate in the &xslt4c; initiative to support EXSLT by testing these implementations or implementing
other EXSLT functions is more than welcome. Please email us at the <human-resource-ref idref="xalandev"/>.</p>
</s2>
<anchor name="xalanns"/>
<s2 title="Xalan namespace">
<p>We are placing the Xalan extension functions in the XalanExtensions module and we have defined a namespace for this module:</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<code>http://xml.apache.org/xalan</code></p>
<p>If you are calling &xslt4c;-supplied extensions, we recommend that you define this namespace in your stylesheet element, and
call the extension using the namespace prefix that you have associated with that namespace. That way, if we later reorganize
how the &xslt4c;-supplied extensions are stored, you won't have to modify your stylesheet.</p>
<p>For an example that uses this namespace, see <link anchor="ex-nodeset">Example with the nodeset extension function</link>.</p>
</s2>
<anchor name="nodeset"/>
<s2 title= "nodeset">
<p>Implemented in <jump href="apiDocs/classFunctionNodeSet.html">FunctionNodeSet</jump>, <code>nodeset (result-tree-fragment)</code>
casts a result tree fragment into a node-set.</p>
<note>When you bind a variable to a template, rather than to the value generated by a select expression, the data type of the variable
is result tree fragment. For more information, see <jump href="http://www.w3.org/TR/xslt#section-Result-Tree-Fragments">Result
Tree Fragments</jump>.</note>
<anchor name="ex-nodeset"/>
<s3 title="Example with the nodeset extension function">
<p>The following stylesheet uses the nodeset extension function to cast a result tree fragment into a node-set that can then be
navigated in standard XPath manner. It uses the http://xml.apache.org/xalan namespace to provide access to the nodeset() method
in xml.apache.xalan.lib.Extensions.</p>
<source>
&lt;?xml version="1.0"?&gt;
&lt;xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0"
xmlns:xalan="http://xml.apache.org/xalan"
exclude-result-prefixes="xalan"&gt;
&lt;xsl:template match="/"&gt;
&lt;out&gt;
&lt;xsl:variable name="rtf"&gt;
&lt;docelem&gt;
&lt;elem1&gt;
&lt;elem1a&gt;ELEMENT1A&lt;/elem1a&gt;
&lt;elem1b&gt;,ELEMENT1B&lt;/elem1b&gt;
&lt;/elem1&gt;
&lt;elem2&gt;
&lt;elem2a&gt;ELEMENT2A&lt;/elem2a&gt;
&lt;/elem2&gt;
&lt;/docelem&gt;
&lt;/xsl:variable&gt;
&lt;xsl:for-each select="xalan:nodeset($rtf)/docelem//*"&gt;
&lt;xsl:value-of select="name(.)"/&gt;&lt;xsl:text&gt;,&lt;/xsl:text&gt;
&lt;/xsl:for-each>
&lt;/out>
&lt;/xsl:template>
&lt;/xsl:stylesheet&gt;
</source>
<p>The output of running this stylesheet (with any XML input source) is a comma-delimited list of the element names in the node-set<br/>
&nbsp;&nbsp;<code>&lt;out&gt;elem1,elem1a,elem1b,elem2,elem2a&lt;/out&gt;</code></p>
<note>For illustration purposes, the preceding stylesheet pays no attention to the structure and content of the XML input document.
Instead, it processes the template (in the stylesheet) bound to the variable named rtf.</note>
</s3>
</s2>
<anchor name="intersection"/>
<s2 title="intersection">
<p>Implemented in <jump href="apiDocs/classFunctionIntersection.html">FunctionIntersection</jump>, <code>intersection (node-set1,
node-set2)</code> returns a node-set with all nodes that are in ns1 and in ns2.</p>
</s2>
<anchor name="difference"/>
<s2 title= "difference">
<p>Implemented in <jump href="apiDocs/classFunctionDifference.html">FunctionDifference</jump>, <code>difference(node-set1,
node-set2)</code> returns a node-set with the nodes in node-set1 and not in node-set2.</p>
</s2>
<anchor name="distinct"/>
<s2 title= "distinct">
<p>Implemented in <jump href="apiDocs/classFunctionDistinct.html">FunctionDistinct</jump>, distinct (node-set) returns a node-set
containing nodes with distinct string values. If more than one node in the node-set contains the same text node value, distinct
only returns the first of these nodes that it finds.</p>
</s2>
<anchor name="evaluate"/>
<s2 title= "evaluate">
<p>Implemented in <jump href="apiDocs/classFunctionEvaluate.html">FunctionEvaluate</jump>, <code>evaluate (xpath-expression)</code>
returns the result of evaluating the xpath-expression in the current XPath expression context (automatically passed in by the
extension mechanism).</p>
<p>Use the evaluation extension function when the value of the expression is not known until run time.</p>
</s2>
<anchor name="hassamenodes"/>
<s2 title= "hasSameNodes">
<p>Implemented in <jump href="apiDocs/classFunctionHasSameNodes.html">FunctionHasSameNodes</jump>, <code>hasSameNodes(node-set1,
node-set2)</code> returns true if both node-set1 and node-set2 contain exactly the same set of nodes.</p>
</s2>
</s1>