DocBook Publishing - Output to HTML

June 6th, 2008 at 23:24 · Filed Under At Work, Documentation, Linux, Software Development · 3 Comments 

I learned about DocBook last year and found it a great tool for technical documentation. It is a XML based semantic markup language. The DocBook is originally intended for computer hardware and software documentation but it is great for other documentation purposes.

I have been working on some documentation, new and converting existing from Lyx to DocBook. With DocBook, I am able to publish the contents easily to many formats, namely TEX, text, pdf or HTML. I had been trying to output some of my DocBook documentation to HTML.

This afternoon, I have finally succeeded to publish to HTML. I installed some DocBook packages on Ubuntu. Here are the packages you need to get DocBook going:

  1. docbook
  2. docbook-xsl
  3. docbook-xsl-doc
  4. docbook-xsl-doc-html
  5. docbook-xsl-doc-pdf
  6. docbook-xsl-doc-text
  7. xsltproc
  8. and optional xalan and fop

To output your DocBook document to HTML, simply this:


$ xsltproc --output paper.html \
/usr/share/xml/docbook/stylesheet/nwalsh/xhtml/docbook.xsl\
paper.xml

You can turn on chapter and section numbering by setting chapter.autolabel to 1 and section.autolabel to 1. To include the chapter number in every sections, set section.label.includes.component.label to 1.


$ xsltproc --output paper.html \
--stringparam section.autolabel 1 \
--stringparam section.label.includes.component.label 1 \
/usr/share/xml/docbook/stylesheet/nwalsh/xhtml/docbook.xsl \
paper.xml