XML technologies / DocBook / Modular documents / Including content with XIncludes / Using XInclude
(Excerpt from "DocBook-XML: Media-neutral and platform-independent publishing" by Thomas Schraitle)
To insert individual files into a DocBook document using XIncludes, place the element xi:include at the appropriate location. The example below shows a master file and a reference to a chapter.
Example: Chapter to include: file docbook-intro.xml
<?xml version="1.0" encoding="UTF-8"?>
<!-- Die einzufügende Datei darf eine DOCTYPE-Deklaration besitzen: -->
<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.docbook.org/xml/4.5/docbookx.dtd">
<chapter id="docbook-intro">
<title>Einführung in DocBook</title>
...
</chapter>Example: Master file as a book: file book.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.docbook.org/xml/4.5/docbookx.dtd">
<book>
<title>DocBook-XML</title>
<para>...</para>
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="docbook-intro.xml" />
...
</book>Line 6: Namespace declaration (with namespace prefix xi) for XInclude. The URI "http://www.w3.org/2001/XInclude" must be written exactly this way for replacement to work; case matters. The xi:include element requires the attribute href, which contains a URI pointing to the file docbook-intro.xml.
In this example, the XML parser attempts to read the file docbook-intro.xml. If successful, the include element is replaced by the content of docbook-intro.xml. If it fails, the parser issues a message.
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