Chapter 6. Extending XSLT
XSLT 1.0 can be extended in two ways: extension functions and extension elements. The EXSLT community project (http://www.exslt.org) defines a number of useful extensions supported by multiple XSLT processors. This chapter contains a complete reference for the EXSLT extensions, including what processors support them. You’ll also find Tip sections that compare individual EXSLT functions with new features in XSLT 2.0 and XPath 2.0.
Extension functions are functions included in an XSLT processor that are not among XSLT 1.0’s built-in set of functions. Unlike built-in functions, they must be namespace-qualified. When a function name includes a namespace prefix (e.g.,
exslt:node-set( )), an XSLT processor interprets it as a call to an extension function.
To test if a particular extension function is available in the current XSLT processor, use the
function-available( ) function.
XSLT 1.0 does not include a built-in mechanism for user-defined functions (unlike XSLT 2.0), but some XSLT processors support EXSLT’s
func:function element, which allows users to define their own functions in XSLT. See the section EXSLT—Functions later in this chapter.
How to Use an Extension Function
Here is an example use of an extension function. This will work in any XSLT processor that supports the EXSLT Dates and Times module:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:date="http://exslt.org/dates-and-times" exclude-result-prefixes="date"> ...