I just looked into ESR’s DocBook Demystification HOWTO. After reading that, I wanted to try to produce PDF output from DocBook XML on my own Linux box which is running Ubuntu.

But neither of the necessary packages for this task which are mentioned in the HOWTO is in Ubuntu feisty. xmlto is there, but needs passivetex, which was in earlier Ubuntu releases, but was removed (It was removed from Debian, too.). fop is also not in Ubuntu, though it is in Debian.

But I found another package in Ubuntu: db2latex-xsl, which contains XSL stylesheets to turn DocBook XML into LaTeX with the help of a XSL processor like xsltproc. The LaTeX file can then be processed with pdflatex to produce PDF.

Here is the shell script I wrote for this:

$ cat ~/bin/db2latex
#!/bin/sh

PATH=/bin:/usr/bin

for i
do
    basename=`basename "$i" .xml`
    xsltproc -nonet -o "$basename.tex" \\
    /usr/share/xml/docbook/stylesheet/db2latex/latex/docbook.xsl "$i"
done

Call this with db2latex foo.xml and then pdflatex foo.tex to get a PDF file foo.pdf from a source file foo.xml.

A New Hope

2007-08-04

Gefunden unter http://xkcd.org/297/: