O'Reilly logo

Beginning XSLT and XPath: Transforming XML Documents and Data by Ian Williams

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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() or cos().

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

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required