Appendix B. Extending XSLT
Having come this far and seen what is available in the standard features of XSLT, you might ask why you'd need to extend it to add functionality.
There are several possible circumstances:
You might want to access data in a source such as a database.
The functions you need are not available in XSLT or XPath—for example, you need to do trigonometric calculations with functions such as
tan()
orcos()
.Additional instructions or attributes are needed.
An application requires customized serialization encodings or parameters.
A collating sequence is necessary for a language that is not provided, and you also need to localize numbers and dates in a way that is not supported.
There are a number of ways to make extensions. Some you can make yourself with stylesheet functions, and there are also open-source XSLT function libraries that you can make use of. Processor vendors may provide extensions of several kinds, including functions, instructions and declarations, additional attributes, and types. It is also possible to define your own extension, usually written in the language of the host XSLT processor.
Stylesheet Functions
A common approach to extending XSLT is to write new stylesheet functions using the <xsl:function>
declaration, whether these are user-written or defined by a third party. These functions use XSLT and XPath, and they are called the same way as other extension functions.
The following is a schema definition. Note that as a declaration, it is a top-level ...
Get Beginning XSLT and XPath: Transforming XML Documents and Data now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.