The Crash Course to DocBook

2.4. My First DocBook File

First, you need a DocBook file to convert. Take any simple text editor you want and type (or cut'n'paste) the following lines:

Example 2-1. A minimal DocBook file


<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN"
  "/usr/share/xml/docbook/schema/dtd/4.4/docbookx.dtd">
 
<book>
 
<bookinfo>
<title>Hello, world</title>
</bookinfo>
 
<chapter>
<title>Hello, world</title>
 
<para>This is my first DocBook file.</para>
 
</chapter>
</book>

Then save it under, say, myfile.docbook. If you are using SGML tools, the long pathname between quotes on the third line is not needed.

To convert this file from DocBook format to HTML format, use the command:


$ docbook2html myfile.docbook
or

$ xsltproc /usr/share/xml/docbook/stylesheet/nwalsh/current/html/docbook.xsl myfile.docbook -o myfile.html
according to your toolkit (DocBook-tools or XSLTProc).

Jade or xsltproc will chug away, and if your document has no errors you will get one or more HMTL files. Use a Web browser to look at them, book1.htm.

If you do get errors, read through the error log and correct errors from the beginning of the list first. Often, an early error such as an unclosed tag will cause a lot more errors to occur later in the document.