XML technologies / DocBook / Structural elements / Books

(Excerpt from "DocBook-XML: Media-neutral and platform-independent publishing" by Thomas Schraitle)

A book consists of several parts, the most important being the preface, table of contents, chapters, appendices, glossary, bibliography, and indexes. There are, of course, other elements, which we will also examine.

DocBook 4

The following example shows a sample book in DocBook 4.

 

Example: Structure of a book in DocBook 4

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
<book lang="de">
    <title>Mein erstes Buch in DocBook</title>
    <titleabbrev>Beispielbuch</titleabbrev>
    <bookinfo>
        <author>
            <firstname>Tux</firstname><surname>Pinguin</surname>
        </author>
        <pubdate>2002, 2003</pubdate>
    </bookinfo>
    <dedication>
        <para>Dieses Buch ist J. S. gewidmet.</para>
    </dedication>
    <preface><!-- Das Vorwort --></preface>

    <!-- Eigentlicher Inhalt des Buches -->

    <glossary>
        <!-- ... -->
    </glossary>
    <bibliography>
        <!-- ... -->
    </bibliography>
    <index/>
</book>

Line 3: The root element with its language
Line 4: Every book should have a title
Line 5: If the title is too long, it can be shortened using titleabbrev.
Line 6: Book metadata. In this case, the author and publication date are specified.
Line 12: A dedication
Line 15: The preface
Line 19: A glossary
Line 24: A bibliography
Line 25: An index. Like <toc/>, it is usually specified as an empty element. The publishing system replaces <index/> with the sorted contents.

Every book should specify the language in which it is written, using the attribute lang (see the attribute lang).

A book also allows an element bookinfo, which can contain information about authors, contributors, publishers, editions, publisher addresses, and so on. The example above shows only two possible elements (author and pubdate).

The exact order in the example is not mandatory. You could place the table of contents at the end of the book if necessary, for example in a novel where it should not reveal the plot to the reader.

DocBook 5

The previous example can also be represented in DocBook 5. Simply add the DocBook namespace, replace lang with xml:lang, and replace bookinfo with the element info. The structure itself is unchanged. DocBook 5 normally has no DOCTYPE declaration. If present, it is used to declare Entities.

In DocBook 5, the content model of a book was extended with an optional element acknowledgement (acknowledgments), shown in the following example.

 

Example: Structure of a book in DocBook 5 with an additional acknowledgement

<book
    version="5.0"
    xmlns='http://docbook.org/ns/docbook'
    xml:lang="de">
    <title>Mein erstes Buch in DocBook</title>
    <acknowledgement>
        <!-- ... -->
    </acknowledgement>
    <!-- ... -->
</book> 

Line 2: The DocBook version.
Line 3: The DocBook namespace
Line 4: The book’s language

Furthermore, info allows the element cover:

Example: Covers using cover

<book>
    <info>
        <cover role="front">
            <para>DocBook-XML</para>
            <para>Medienneutrales und plattformunabhängiges Publizieren</para>
            <mediaobject>
                <imageobject>
                    <imagedata fileref="cover.png"/>
                </imageobject>
            </mediaobject>
        </cover>
        <cover role="back">
            <para>Texte und technische Dokumentationen werden heute...</para>
            <!-- ... -->
        </cover>
    </info>
</book>

The cover element is used for additional material, such as front and back covers, spines, dust jackets, and so on. Since this naturally involves many variations, DocBook defines no specific semantics for it. It is therefore useful to customize the stylesheets to suit your own requirements.

If you are creating a PDF and the cover is produced separately, cover is probably of little interest. Omit it and later combine the book and cover PDFs with a suitable program such as pdftk when a complete book is required.

  

back to top