Splitting The Document

If the document to be written is fairly complex in structure or big in size it may be advisable to split it into several logical chunks that are held in separate files (e.g the chapters of a book). In this case there should be a top-level document that "includes" the sub-level documents.

The method for doing so is rather simple. The top-level document defines some entities that refer to the files holding the sub-sections of the document. After that the entities are used in exactly the order the subsections shall occur.

Example 3-18. Document Splitting (top-level document)


	    <?xml version="1.0" encoding='ISO-8859-1'?>
	    <!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook V3.1//EN" [
	    <!ENTITY chapter1 SYSTEM "chap1.xml">
	    <!ENTITY chapter2 SYSTEM "chap2.xml">
	    <!ENTITY chapter3 SYSTEM "chap3.xml">
	    <!ENTITY appendix_a SYSTEM "appa.xml">
	    <!ENTITY appendix_b SYSTEM "appb.xml">
	    ]>
	    <book><title>My First Book</title>
	    &chapter1;
	    &chapter2;
	    &chapter3;
	    &appendix_a;
	    &appendix_b;
	    </book>
	    
	  

The sub-level document simply contains the chapter, section or whatever.

Example 3-19. Document Splitting (sub-level document)


	    <?xml version="1.0" encoding='ISO-8859-1'?>
	    <chapter id="ch1"><title>My First Chapter</title>
	    <para>My first paragraph.</para>
	    ...
	    
	  

Warning

These files do not and must not have document type declarations! Only top-level documents have this information and pass it to the sub-level documents (inheritance).