XML technologies / DocBook / Modular documents / Adding XIncludes to DocBook 4.x

(Excerpt from "DocBook-XML: Medienneutrales und plattformunabhängiges Publizieren" by Thomas Schraitle)

This section is only needed if you want to validate a DocBook 4 document containing XIncludes without resolving the XInclude elements to their referenced resources.

Version 4.x of the DocBookDTD does not recognize XIncludes. Your XML editor therefore cannot offer these elements when you write a DocBook document. Fortunately, allowing them at certain positions takes little effort. Proceed as follows:

  1. First create the file xinclude.mod with the following content:

<!ENTITY % xmlnsxi 'xmlns:xi CDATA #FIXED "http://www.w3.org/2001/XInclude"'> 
<!ELEMENT xi:include (xi:fallback?) > 
<!ATTLIST xi:include 
     %xmlnsxi; 
     href CDATA #IMPLIED 
     parse (text|xml) "xml" 
     xpointer CDATA #IMPLIED 
     encoding CDATA #IMPLIED 
     accept CDATA #IMPLIED 
     accept-charset CDATA #IMPLIED 
     accept-language CDATA #IMPLIED 
     > 
<!ELEMENT xi:fallback ANY > 
<!ATTLIST xi:fallback %xmlnsxi; >

  1. Add the following code to the file in which you want to allow XInclude elements:

<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.docbook.org/xml/4.5/docbookx.dtd" 
[ 
 <!ENTITY % xinclude SYSTEM "xinclude.mod"> 
 %xinclude; 

 <!ENTITY % local.chapter.class "| xi:include"> 
 <!ENTITY % local.section.class "| xi:include"> 
 <!ENTITY % local.info.class "| xi:include"> 
 <!-- Folgende Zeile nur für DocBook 4.2 und früher auskommentieren --> 
 <!-- <!ENTITY % local.common.attrib "xml:base CDATA #IMPLIED"> --> 
]> 
<book>...</book>

  1. Uncomment the entity declaration %local.common.attrib; in the preceding step if you use DocBook 4.2 or earlier.

  2. Apply the change from step 2 to every file in which you want to use XInclude elements.

These changes let you validate an XML file without having to resolve XInclude elements.

  

back to top