Xalan-C++ 1.10
What's New
Build Instructions
Sample Apps
Command Line
Usage Patterns
Extensions Library
API Reference

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 Xalan-C++. If you have ideas and/or contributions you would like to make, please email us at the Xalan Development Mailing List.

EXSLT extensions

Xalan-C++ supports the EXSLT initiative to provide a set of standard extension functions to XSLT users. Xalan-C++ includes beta implementations for functions in four of the EXSLT namespaces (some are calls to extension already in the Xalan namespace).

The source files for the implementations are in the XalanEXSLT subdirectory of the source tree. See

For the function specifications, see:

Anyone who would like to participate in the Xalan-C++ initiative to support EXSLT by testing these implementations or implementing other EXSLT functions is more than welcome. Please email us at the Xalan Development Mailing List.

Xalan namespace

We are placing the Xalan extension functions in the XalanExtensions module and we have defined a namespace for this module:


If you are calling Xalan-C++-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 Xalan-C++-supplied extensions are stored, you won't have to modify your stylesheet.

For an example that uses this namespace, see Example with the nodeset extension function.


Implemented in FunctionNodeSet, nodeset (result-tree-fragment) casts a result tree fragment into a node-set.

NoteWhen 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 Result Tree Fragments.
Example with the nodeset extension function

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.

<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
<xsl:template match="/">
	  <xsl:variable name="rtf">
      <xsl:for-each select="xalan:nodeset($rtf)/docelem//*">
        <xsl:value-of select="name(.)"/><xsl:text>,</xsl:text>

The output of running this stylesheet (with any XML input source) is a comma-delimited list of the element names in the node-set

NoteFor 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.


Implemented in FunctionIntersection, intersection (node-set1, node-set2) returns a node-set with all nodes that are in ns1 and in ns2.


Implemented in FunctionDifference, difference(node-set1, node-set2) returns a node-set with the nodes in node-set1 and not in node-set2.


Implemented in FunctionDistinct, 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.


Implemented in FunctionEvaluate, evaluate (xpath-expression) returns the result of evaluating the xpath-expression in the current XPath expression context (automatically passed in by the extension mechanism).

Use the evaluation extension function when the value of the expression is not known until run time.


Implemented in FunctionHasSameNodes, hasSameNodes(node-set1, node-set2) returns true if both node-set1 and node-set2 contain exactly the same set of nodes.

Copyright © 1999-2004 The Apache Software Foundation. All Rights Reserved.