XML technologies / DocBook / Modular documents / Including content with XIncludes / Handling errors
(Excerpt from "DocBook-XML: Media-neutral and platform-independent publishing" by Thomas Schraitle)
If loading a resource causes an error, fallback handles it. Inside fallback you may insert anything also permitted in place of include: either elements or text.
If the example ‘Combined file as a book: file book.xml’ is extended with the element fallback, it becomes:
Example: Handling errors with xi:fallback
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="docbook-intro.xml">
<xi:fallback>
<para>
<emphasis>Datei docbook-intro.xml nicht gefunden!</emphasis>
</para>
</xi:fallback>
</xi:include>If docbook-intro.xml is not found, a paragraph is inserted there. After resolving XInclude, the file looks as follows:
<para>
<emphasis>Datei docbook-intro.xml nicht gefunden!</emphasis>
</para>Note that the document must be valid after resolution. In place of xi:include a para element is allowed, but not an emphasis element. Therefore, the following xi:include element produces an invalid document:
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="docbook-intro.xml">
<xi:fallback>
<emphasis>Datei docbook-intro.xml nicht gefunden!</emphasis>
</xi:fallback>
</xi:include>
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