DocBook Publishing - Output to HTML

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

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

Comments

3 Responses to “DocBook Publishing - Output to HTML”

  1. Ralph Boland on July 5th, 2008 23:18

    I haven’t yet tested whether the things downloaded
    allows me to create Docbook documents (I will be using lyx to do this and haven’t gotten docbook to
    work with lyx yet.
    However I did run into some downloading problems:

    1) I assume “docbook-xsl-doc-pd” is really:
    “docbook-xsl-doc-pdf”

    2) installing both “docbook-xsl-doc-pdf” and “docbook-xsl-doc-text” reported errors about overwriting
    files already created when “docbook-xsl-doc-pdf”
    was installed.

    The synaptic package manager never found any
    “fop” to install.

    I am running Ubuntu hardy on a vanilla PC.

    Thanks for the web site. It’s a big help.

    Ralph Boland

  2. Adrian Hoe on July 6th, 2008 0:13

    Yes. It is “docbook-xsl-doc-pdf”. It was a typo and thanks for spotting.

    You can find package “fop” at Docbook site. It is not included in Ubuntu distribution.

    You will need a XML editor to create your documents. Then you use xsltproc to generate required output.

    Hope that helps.

  3. 郝云彩 on August 22nd, 2008 10:17

    Thanks for the tips. I am able to output to html but not pdf. Do I need fop package to output to pdf? Perhaps I have overlook, I can’t find fop.

Leave a Reply