XML technologies / DocBook / Generating (X)HTML / An example transformation / The transformation
(Excerpt from "DocBook-XML: Media-neutral and platform-independent publishing" by Thomas Schraitle)
To convert your DocBook document to XHTML you need an XSLT processor (xsltproc, Saxon or Xalan) and the DocBook stylesheets. The following options are available (see Customizing DocBook XSL stylesheets):
Use the original stylesheets. Replace the placeholder
DBwith the DocBook stylesheets’ installation directory and run:
xsltproc --output pinguin.html DB/xhtml/docbook.xsl pinguin.xmlUse parameters to change settings quickly without writing a customization file. For example, the parameter
html.stylesheetlinks every XHTML file to a CSS file (all on one line):
xsltproc --stringparam html.stylesheet "book.css" DB/xhtml/docbook.xsl pinguin.xmlWrite a customization file. This is the most flexible option, though slightly more involved. It simplifies the invocation of
xsltproc, since parameters no longer need to be specified. Templates can also be overridden to implement your own requirements.
Write your customization file, for example:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:import href="DBBASISURI/xhtml/docbook.xsl"/>
<xsl:param name="html.stylesheet">book.css<xsl:param>
</xsl:stylesheet>Replace the placeholder
DBBASISURIwith the corresponding official URI; see the table Base URIs for DocBook 4 and DocBook 5.
Save the stylesheet, for example as
mydb2xhtml.xsl.Run the XSLT processor with your stylesheet:
xsltproc --output pinguin.html mydb2xhtml.xsl pinguin.xml These transformations can also use the stylesheet xhtml/chunk.xsl. It splits the document into linked XHTML files, suitable for documents too large to load as a whole in a browser.
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