XML technologies / DocBook / Modular documents / Including using external entities
(Excerpt from "DocBook-XML: Media-neutral and platform-independent publishing" by Thomas Schraitle)
To include individual files in a DocBook document through external entities, use the internal subset of the DTD:
Example: Master file and referencing of files
<?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"
[
<!ENTITY Info-Buch SYSTEM "bookinfo.xml">
<!ENTITY Info-XML SYSTEM "xmlinfo.xml">
<!ENTITY Datenbank SYSTEM "dbinfo.xml">
]>
<book>
<title>Das erste DocBook-Buch</title>
&Info-Buch;
&Info-XML;
&Datenbank;
</book>Lines 6 to 8: Declare an external entity referencing a file.
Lines 13 to 15: Use the defined reference target.
The DTD’s internal subset defines three external entities: &Info-Buch;, &Info-XML; and &Datenbank;. In the example above, they point to chapter files that can be edited independently. A chapter in the file xmlinfo.xml might look like this:
<?xml version="1.0" encoding="UTF-8"?>
<!-- Keine DOCTYPE Deklaration! -->
<chapter id="chap.xmlinfo">
<title>Einführung in XML</title>
<para>Dies ist ein kleiner Absatz in unserem Kapitel.</para>
<!-- weitere Einträge ... -->
</chapter>These files may have an XML declaration but must not have a DOCTYPE declaration! The XML specification forbids it. Without a DOCTYPE declaration, these files cannot be validated on their own; the master file is always required.
Copyright © 2009 Millin Verlag
You may print the online version for your private use.
Otherwise, this chapter from "DocBook-XML: Medienneutrales und plattformunabhängiges Publizieren" is subject to the same provisions as the printed edition: the work, including all its parts, is protected by copyright. All rights are reserved, including reproduction, translation, microfilming, and storage and processing in electronic systems.
Millin Verlag, Siebengebirgsring 36, 53797 Lohmar, info(at)millin.de
back to top