XML technologies / DocBook / Modular documents / Including content with XIncludes / Including text
(Excerpt from "DocBook-XML: Media-neutral and platform-independent publishing" by Thomas Schraitle)
Unlike external entities XIncludes can insert a referenced file as either XML or text. XML is the default. To read a file as text, specify the attribute parse with the value text (the default is xml):
Example: Including text using XIncludes
<programlisting><xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="parse.py" parse="text" /></programlisting>When read, special characters such as ampersand (&) and less-than (<) are replaced by the predefined entities & and <.
This method is often used for external code, allowing code and documentation to be maintained separately. Changes to the code automatically appear in the documentation, so only one file needs editing.
The drawback is that the entire file must be included. Individual lines cannot be hidden with this method.
Note: Avoiding accidental whitespace
Whitespace is preserved in the elements programlisting and screen and also between <screen> and <xi:include>. Remove spaces, line breaks and similar whitespace between these tags to avoid unwanted whitespace (see the example above).
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