Appendix C. Getting started with XML/DocBook

Table of Contents

C.1. What is XML/DocBook
C.2. Installing the necessary tools
C.3. Using the tools
C.4. Links

This appendix describes the installation of the tools needed to produce a formatted version of the NetBSD guide. Besides that it contains instructions that describe how to build the guide.

C.1. What is XML/DocBook

XML (eXtensible Markup Language) is a language which is used to define other languages based on markups, i.e. with XML you can define the grammar (i.e. the valid constructs) of markup languages. HTML, for example, can be defined using XML. If you are a programmer, think of XML like the BNF (Backus-Naur Form): a tool used to define grammars.

DocBook is a markup template defined using XML; DocBook lists the valid tags that can be used in a DocBook document and how they can be combined together. If you are a programmer, think of DocBook as the grammar of a language specified with the BNF. For example, it says that the tags:

<para> ... </para>

define a paragraph, and that a <para> can be inside a <sect1> but that a <sect1> cannot be inside a <para>.

Therefore, when you write a document, you write a document in DocBook and not in XML: in this respect DocBook is the counterpart of HTML (although the markup is richer and a few concepts are different).

The DocBook specification (i.e. the list of tags and rules) is called a DTD (Document Type Definition).

In short, a DTD defines how your source documents look like but it gives no indication about the format of your final (compiled) documents. A further step is required: the DocBook sources must be converted to some other representation like, for example, HTML or PDF. This step is performed by a tool like Jade, which applies the DSSSL transforms to the source document. DSSSL (Document Style Semantics and Specification Language) is a format used to define the stylesheets necessary to perform the conversion from DocBook to other formats. The build structure for the guide also supports the XSL (Extensible Stylesheet Language) stylesheet language. The xsltproc program is used for transforming XML with XSL stylesheets.

C.2. Installing the necessary tools

All the tools that are needed to generate the guide in various formats can be installed through the netbsd-www, netbsd-doc, and netbsd-doc-print meta-packages. Together the netbsd-doc and netbsd-www packages install everything that is needed to generate the HTML version of the guide. To be able to generate printable formats, such as Postscript and PDF, install the netbsd-doc-print meta-package.

Supposing that a current pkgsrc tree is installed at /usr/pkgsrc, you can install all these meta-packages with:

$ cd /usr/pkgsrc/meta-pkgs/netbsd-www
$ make install
$ cd /usr/pkgsrc/meta-pkgs/netbsd-doc
$ make install
$ cd /usr/pkgsrc/meta-pkgs/netbsd-doc-print
$ make install

C.3. Using the tools

This section provides an overview of how the guide can be compiled from XML to any of the following target formats: html, html-split, ascii, ps, and pdf. Creating all formats is the default. To produce any of the above output formats, run make with the format(s) as argument.

Let's look at a few examples.

Before looking at the output generated in any of the above-mentioned formats, integrity of the XML structure has to be ensured. This can be done by running make lint:

$ cd htdocs/docs/guide/en
$ make lint

Fix any errors you may get. When working on the contents of the guide, you may want to produce the HTML version to have a look at it for proofreading:

$ cd htdocs/docs/guide/en
$ make html-split

After this, please update the Postscript and PDF versions of the guide too. The command for this is:

$ cd htdocs/docs/guide/en
$ make pdf

Before you commit the generated files, please make sure that you commit the XML files first, then re-generate all formats, i.e. the procedure would be something like:

$ cd htdocs/docs/guide/en
$ cvs commit *.xml
$
$ make lint
$ make
$ make install-doc
$
$ cd ..
$ cvs commit en download 

When running make with no argument, all formats will be re-generated. This is the default way to build the guide for the NetBSD.org website.

C.4. Links

The official DocBook home page is where you can find the definitive documentation on DocBook. You can also read online or download a copy of the book DocBook: The Definitive Guide by Norman Walsh and Leonard Muellner.

For DSSSL start looking at http://nwalsh.com.

XSL is described at http://www.w3.org/Style/XSL/.

Jade/OpenJade sources and info can be found on the OpenJade Home Page.

If you want to produce Postscript and PDF documents from your DocBook source, look at the home page of JadeTex.