XML technologies / DocBook / The DocBook XSL stylesheets / Extension functions and extension elements
(Excerpt from "DocBook-XML: Media-neutral and platform-independent publishing" by Thomas Schraitle)
The author Norman Walsh has provided for Saxon and Xalan extensions written in Java that would be impossible or very difficult to implement with standard XSLT. An equivalent for xsltproc is in preparation.
The following problems are difficult or impossible to solve using XSLT alone:
- Determining an image’s width and height
XSLT cannot determine an image’s width and height. The following extension functions are therefore provided:
getWidthandgetDepth.- Calculating table column widths
The CALS table model supports absolute (3cm) and relative (2*) column widths, as well as a combination (2*+3mm) of both. Although XSL-FO has a corresponding attribute (
proportional-column-width), HTML has no equivalent. For this purpose, the extension functionadjustColumnWidthscalculates the absolute column widths.- Callouts
Callout positions can also be specified outside the text (see Callouts). The extension function
insertCalloutsinserts these callouts into the relevant text.- Text insertion
DocBook uses
textdatato reference external, non-XML text data. XSLT 1 has no mechanism for inserting external text files. The extension functioninsertfileremedies this limitation.- Line numbering
Numbered program listings are possible in XSLT 1 with some effort. The extension function
numberLinesmakes this task easier.
To use extension functions, you need Saxon or Xalan and must enable the appropriate parameters in the following table, “Extension function parameters”. Set the value to 1. By default, all extension functions (except use.extensions) are set to 1 (= on).
Table: Extension function parameters
Parameters | Description |
| the “master switch”, without which nothing works; one of the following parameters must also be enabled. |
| used to position callouts |
| enables line numbering, as in |
| enables calculation of table column widths. |
| enables text insertion. |
| enables calculation of image width and depth. |
To enable extended callout handling, invoke Saxon as follows:
saxon -o OUTFILE XML_FILE XSLT_FILE \
use.extensions="1" callouts.extension="1" ...The equivalent invocation with Xalan is as follows:
xalan -OUT OUTFILE -IN XML_FILE -XSL XSLT_FILE \
-PARAM use.extensions "1" -PARAM callouts.extension "1"
Copyright © 2009 Millin Verlag
You may print the online version for your private use.
Otherwise, this chapter from "DocBook-XML: Medienneutrales und plattformunabhängiges Publizieren" is subject to the same provisions as the printed edition: the work, including all its parts, is protected by copyright. All rights are reserved, including reproduction, translation, microfilming, and storage and processing in electronic systems.
Millin Verlag, Siebengebirgsring 36, 53797 Lohmar, info(at)millin.de
back to top