A Saxon extension function is invoked using a name such as saxon:localname()
.
The saxon
prefix (or whatever prefix you choose to use) must be associated with the
Saxon namespace URI http://saxon.sf.net/
.
For example, to invoke the saxon:evaluate()
function, write:
<xsl:variable name="expression"
select="concat('child::', $param, '[', $index, ']')"/>
..
<xsl:copy-of select="saxon:evaluate($expression)"
xmlns:saxon="http://saxon.sf.net/"/>
The extension functions supplied with the Saxon product are as follows:
saxon:dayTimeDuration-from-seconds(): converts a number of seconds into a duration
saxon:decimal-divide(): performs decimal division with user-specified precision
saxon:discard-document(): marks a document as being eligible for garbage collection
saxon:distinct(): eliminates duplicate values from a set of nodes
saxon:eval(): evaluates a stored expression created using saxon:expression
saxon:evaluate(): evaluates an XPath expression supplied dynamically as a string
saxon:expression(): creates a stored expression for subsequent evaluation using saxon:eval()
saxon:get-pseudo-attribute(): parses the content of a processing instruction
saxon:has-same-nodes(): tests whether two sequences contain the same nodes
saxon:highest(): finds the nodes having the highest value for some expression
saxon:leading(): finds the values in a sequence up to the first one that doesn't match a condition
saxon:line-number(): gets the line number of the current node in the source document
saxon:lowest(): finds the nodes having the lowest value for some expression
saxon:max(): finds the maximum value of a set of nodes
saxon:min(): finds the minimum value of a set of nodes
saxon:parse(): parses an XML document supplied as a string
saxon:path(): returns an XPath expression that identifies the context node
saxon:serialize(): returns the XML representation of a document or element, as a string
saxon:sum(): sums the result of computing an expression for every node in a sequence
saxon:system-id(): returns the system ID of the document containing the context node
saxon:tokenize(): splits a string into a sequence of tokens
saxon:type-annotation(): returns the type annotation of a node
saxon:yearMonthDuration-from-months(): constructs a yearMonthDuration from an integer number of months
The Java source code of these functions (which in most cases is extremely simple),
can be used as an example for writing
other user extension functions. It is found in class
net.sf.saxon.functions.Extensions
. Source code is available in the
download of Saxon-B from SourceForge