Docbook introduction

Docbook is a specification for writing documentation in XML*. Once an XML document containing the data content of the documentation has been created, it can be processed by XSL transforms to produce an output format (pdf, html, chm and more…). This proved particularly useful for a project at work, where I generated a set of output formats from a single XML data source.

Tools, examples and resources after the jump.


I used xsltproc to run the transforms. A windows version can be downloaded from:

Docbook XSLT’s can be found here:

Apache FOP is needed to output to PDF:

Example usage:
Assuming you already have an input xml file (test.xml), you can use the following commands to generate outputs:

xsltproc --output test.html ../docbook-xsl/html/docbook.xsl test.xml

xsltproc --output ../docbook-xsl/fo/docbook.xsl test.xml
fop.bat -fo -pdf test.pdf

xsltproc ..\docbook-xsl\htmlhelp\htmlhelp.xsl test.xml
"C:\Program Files\HTML Help Workshop\hhc" htmlhelp.hhp

Here is a very basic example input xml file (test.xml):

<?xml version="1.0"?>
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
"" >
<book><title>Test Documentation</title>
   <chapter><title>First chapter</title>
         First chapter content. Paragraph One.
         Paragraph two.
   <chapter><title>Chapter two</title>
         Chapter two content. Paragraph One.
         <graphic fileref="test.png"></graphic>

Here is some documentation that I found particularly useful:

“DocBook: The Definitive Guide” – O’Reilly, v.good reference section.

* I think there is an older SGML variation of Docbook as well.

This entry was posted in technology and tagged , . Bookmark the permalink.

1 Response to Docbook introduction

  1. Tom says: is a web service for DocBook XML to PDF conversion

Leave a Reply

Your email address will not be published.