XML technologies / DocBook / Modular documents / Including with XIncludes
(Excerpt from "DocBook-XML: Media-neutral and platform-independent publishing" by Thomas Schraitle)
XML Inclusion, or XInclude, is a W3C specification defining two elements (include and fallback) in the namespace "http://www.w3.org/2001/XInclude" with associated attributes. The include element references a file and is replaced with its XML or text content during resolution. If inclusion fails, an optional fallback child element is used.
Compared with external entities the advantages are:
All files included through XInclude may have a DOCTYPE declaration and be validated individually. More precisely, this succeeds only if a cross-reference and its ID (
idorxml:id) are in the same file. If they are in different files, validation fails.If replacement of the
includeelement fails, the elementfallbackis processed. It can contain furtherincludeor other elements. This allows warnings when files are missing, making errors easier to detect. For details and an example, see Handling errors.XIncludes are elements rather than syntactic constructs such as entities. Using XSLT or any programming language, you can find them to list included files. XSLT cannot identify external entities because they have already been resolved before transformation.
To include only part of a document, XInclude allows the attribute
xpointerto contain an XPointer expression (see Partial inclusion with XPointer). This limits inclusion to the desired XML objects.XInclude elements can be nested: an included file can itself contain XIncludes, allowing further modularization.
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