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):

  1. Use the original stylesheets. Replace the placeholder DB with the DocBook stylesheets’ installation directory and run:

xsltproc --output pinguin.html DB/xhtml/docbook.xsl pinguin.xml

  1. Use parameters to change settings quickly without writing a customization file. For example, the parameter html.stylesheet links every XHTML file to a CSS file (all on one line):

xsltproc --stringparam html.stylesheet "book.css" DB/xhtml/docbook.xsl pinguin.xml

  1. Write 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.

  1. 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 DBBASISURI with the corresponding official URI; see the table Base URIs for DocBook 4 and DocBook 5.

  1. Save the stylesheet, for example as mydb2xhtml.xsl.

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

  

back to top