XML technologies / DocBook / The DocBook XSL stylesheets / Stylesheet overview / Which stylesheet variant should you use?
(Excerpt from "DocBook-XML: Media-neutral and platform-independent publishing" by Thomas Schraitle)
The short answer to the question in the title is: use the original stylesheets for DocBook 4 and the DocBook XSL NS stylesheets for DocBook 5. The longer, more detailed answer is that both variants can in principle be used with either DocBook version, though with minor limitations. This section briefly explains the background.
The main difference between DocBook 5 and earlier versions is the namespace "http://docbook.org/ns/docbook". However, the original stylesheets recognize only DocBook elements that are not bound to a namespace. Consequently, they do not recognize DocBook 5 elements.
To recognize DocBook 5 elements and transform them into your target format, the original stylesheets use a trick: if they detect the DocBook 5 namespace on the root element, the document is processed in the mode stripNS. As its name suggests, this mode removes only the DocBook namespace from each DocBook 5 element, leaving the document structure intact. The result is stored temporarily in a variable and converted into a node-set. This makes the original stylesheets behave as if they had DocBook 4 elements, allowing the predefined template rules to be applied.
The alternative for DocBook 5 would be to write stylesheets that recognize the DocBook namespace. This is technically straightforward, but would require maintaining two stylesheet variants differing only in minor additions. That would increase maintenance work. To avoid this, Bob Stayton wrote a Perl script based on the existing original stylesheets. The Perl script examines the XSLT attributes count, from, match, use, select and test and adds the following to each DocBook element: a prefix. The DocBook namespace is also added to the root element. Thus, <xsl:template match="chapter"> becomes <xsl:template match="d:chapter">.
Using the DocBook XSL NS stylesheets for your DocBook 5 documents offers the following advantages:
The stylesheets are designed specifically for DocBook 5 and require no “hacks”. This reduces memory consumption, since the entire document no longer needs to be stored temporarily in a variable.
You can write a customization file that takes the DocBook namespace into account.
The attribute
xml:baseon the root element is not lost during processing with the original stylesheets. This attribute is taken into account when using images or OLink databases.
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