Setting Up Docbook
Contents
Introduction
This solutions are based on free tools and on some information from internet.
Installation, Setup
Install script: install.sh Editor: xxe. Converter: xml2pdf.sh.
Installation, Setup on Centos 5
Installation, Setup on FreeBSD 8
Installation, Setup on SuSe 11.3
Documentation (links)
Examples and Running
Submittal Header XML in Smarty Template
Installation, Setup on MacOS X
Requirements for PDF generation:
Apache XML Commons Resolver available here
Apache XML Commons Resolver
Get resolver.jar here
- Unpack and move to ...
sudo mv -i ~/Downloads/xml-commons-resolver-1.2 /usr/share/java/
- Add location to CLASSPATH in .bashrc
CLASSPATH=$CLASSPATH":/usr/share/java/xml-commons-resolver-1.2/resolver.jar"
Apache FOP
Get Apache FOP
- Unpack and move ...
sudo mv -i ~/Downloads/fop-1.0 /usr/local/
- Create symbolic links for ~/Library/Java/Extensions/
ln -s /usr/local/fop-1.0/lib/*.jar ~/Library/Java/Extensions/ ln -s /usr/local/fop-1.0/build/fop.jar ~/Library/Java/Extensions/
DocBook
Get DocBook
- Unpack and move ...
sudo mv -i ~/Downloads/docbook-xsl-1.76.1 /usr/local/
- Go there and run installation ...
cd /usr/local/docbook-xsl-1.76.1/ ./install.sh
- Test if everything went fine ...
./test.sh
Examples
DocBook to HTML
Copy the following UTF-8 encoded and save as docbook-test.xml:
<!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
"http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd">
<article>
<articleinfo>
<author><firstname>Norman</firstname><surname>Walsh</surname></author>
<authorinitials>ndw</authorinitials>
<artpagenums>339-343</artpagenums>
<volumenum>15</volumenum>
<issuenum>3</issuenum>
<publisher><publishername>The TeX User's Group</publishername></publisher>
<pubdate>1994</pubdate>
<title>A World Wide Web Interface to CTAN</title>
<titleabbrev>CTAN-Web</titleabbrev>
<revhistory>
<revision>
<revnumber>1.0</revnumber>
<date>28 Mar 1994</date>
<revremark>Submitted.</revremark>
</revision>
<revision>
<revnumber>0.5</revnumber>
<date>15 Feb 1994</date>
<revremark>First draft for review.</revremark>
</revision>
</revhistory>
</articleinfo>
<para>
The body of the article …
</para>
</article>Now you can generate a chunked XHTML (separate HTML pages for each document section) with style file chunked.xsl using xsltproc ...
xsltproc /usr/local/docbook-xsl-1.76.1/xhtml/chunk.xsl docbook-test.xml
This should generate you index.html.
DocBook to PDF
Copy the following UTF-8 encoded and save as book.xml:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE set SYSTEM ".\dtds\docbookx.dtd">
<set>
<book>
<chapter>
<title>Mein erstes Kapitel</title>
<para>Hier ist ein Absatz</para>
<sect1>
<title>Ein Abschnitt im Kapitel</title>
<para>Mindestens ein Absatz im Aschnitt macht ihn DTD-Gerecht.</para>
</sect1>
</chapter>
</book>
</set>PDF generation requires to first create a FO file ...
xsltproc --output book.fo /usr/local/docbook-xsl-1.76.1/fo/docbook.xsl book.xml
Now, generate the PDF from the resulting FO source ...
java org.apache.fop.cli.Main -fo book.fo -pdf book.pdf
This should give you book.pdf.
Have fun!