Including Document Parts with DTD Entities

There are two conditions for including a part using DTD entities:

  • The master document should declare the DTD to be used, while the external entities should declare the XML sections to be referenced.

  • The document containing the section must not define again the DTD.

A master document looks like this:

<?xml version="1.0" encoding="UTF-8"?> 
<!DOCTYPE book SYSTEM "../xml/docbookx.dtd" [ 
<!ENTITY testing SYSTEM "testing.xml" > ]
> 
<book> 
<chapter> ...

The referenced document looks like this:

<section> ... here comes the section content ... </section>

Note

The indicated DTD and the element names (section, chapter) are used here only for illustrating the inclusion mechanism. You can use any DTD and element names you need.

At a certain point in the master document there can be inserted the section testing.xml entity:

... &testing; ...

When splitting a large document and including the separate parts in the master file using external entities, only the master file will contain the Document Type Definition (the DTD) or other type of schema. The included sections can not define the schema again because the main document will not be valid. If you want to validate the parts separately you have to use XInclude for assembling the parts together with the master file.

Was this helpful?