Chapter 3. Structure

DocBook documents are SGML documents. That includes DocBook XML documents as well; XML is a subset of SGML. The SGML declaration at the top identifies it as a DocBook document, and it should look something like this:

<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
 "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd"[
…
]>
<book>
…
</book>
  

The book here specifies the type of the top-level element of the document. This declaration also says that the document conforms to version 4.2 of the DocBook XML document type declaration (DTD). The book element is also shown (although without its content)—notice that it is opened with “<book>” and closed with “</book>”, and everything in between is the content of that element.

Other files can be included by the top-level file by the use of entities. To include a file you first declare an entity and then use it:

<!DOCTYPE …[
<!ENTITY includedfile SYSTEM "includedfile.xml">
]>
…
&includedfile;
…
  

Because SGML tags (<…>) and entities (&…;) are interpreted specially, there are escapes provided to enable you to use these marker characters in your DocBook files. “&lt;” gives “<”; “&gt;” gives “>”; and “&amp;” gives “&”. There are many other predefined entities too.