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 &amp; and &lt;.

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).

  

back to top