5. Using the Tools

This is a terse introduction to using the DocBook tools to compile sgml documents. I won't go into the details of DocBook mark up. See DocBook: The Definitive Guide for complete information on writing DocBook markup.

5.1. A Simple docbook sgml document

Below is an example of a very simple docbook sgml document; a book. Copy it into a text file and we'll compile it into HTML and RTF in a minute.

test.sgml [text]


<!DOCTYPE book PUBLIC "-//OASIS//DTD docbook sgml V4.2//EN" 
                         "http://www.oasis-open.org/docbook/sgml/4.2/docbook.dtd" 
[
 <!ENTITY version "0.01">
]>

<!-- 
Comments just like html
-->

<book>

  <bookinfo>
    <title>Simple XML Sample</title>
    <author>
      <firstname>John</firstname>
      <surname>Doe</surname>
    </author>
    <copyright><year>2002</year><holder>John Doe</holder></copyright>
    <legalnotice>
      <para>This legal mumbo jumbo will stop evil.</para>
    </legalnotice>
    <abstract>
      <para>This is Simple XML Sample version &version;. It is good for nothing but processing.</para>
    </abstract>
  </bookinfo>

  <chapter>
    <title>About this book</title> 
    <para>
      This book was not hard.
    </para>
    
    <section>
    <title>Copyrights and Trademarks</title>
    <para>Copyright &copy; 2002 John Doe</para>
    </section>

    <section><title>Purpose/Scope</title> 
    <para>This guide is tightly scoped with one purpose; to process.</para>
    </section>
  </chapter>

  <appendix><title>References</title>
    <para>Some Hoity Toity Person</para>
  </appendix>

</book>


5.2. Generating HTML and RTF

You can see that DocBook markup is simple. Now let's compile this test.sgml into linux doc project style HTML.

openjade -t sgml -d $SGMLHOME/dsssl/html/ldp.dsl#html test.sgml
      

After, processing you should have the following (or similar) in the folder with test.sgml. Look at index.html in a web browser.

a23.html  index.html  test.sgml  x20.html
c14.html  ln10.html   x17.html

Try compiling RTF using the following. Examine test.rtf in your word processor.

openjade -t rtf -d $SGMLHOME/dsssl/docbook/print/ldp.dsl#print test.sgml

Here's a description of the command line switces:

That's all there is to it. Once you figure out TeX and RTF you can convert to other popular document formats with other tools. You might use TeX, LaTeX, PDF, PDB, or even some unmentioned proprietary formats and tools.