You can include the same content in more than one place in a document as long as it is valid. One thing that can make a document invalid is duplicate ID names. If any duplicated content has an ID attribute on any of the elements in it, then you will have duplicate ID names and your document won't be valid. One drastic solution is to eliminate all ID values from modular doc. But that prevents you from forming cross references to that content. If you use IDs to form HTML filenames in your output, then you won't have that feature for such modules and they will have generated filenames.
If you absolutely must have duplicated content with IDs, then you have to figure out how to get different ID values. The following is one example of how XInclude can give you a different ID value.
Let's say your modular file has a single section you want to include twice, but it has an ID value.
<?xml version="1.0"?> <!DOCTYPE section SYSTEM "docbook.dtd"> <section id="original-id"> <para> blah blah </para> </section>
Form your first XInclude normally:
<xi:include href="module.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
This pulls in the entire <section id="original-id">
element, including its children.
Put your second XInclude inside its own section
element with a different ID value. And avoid the original ID value by selecting the children of the section
element with an XPointer expression. The following is the complete example with both includes.
<book> <chapter> blah blah <xi:include href="module.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/> </chapter> <appendix> blah blah <section id="appendix-id"> <xi:include href="module.xml" xpointer="xpointer(/section/*)" xmlns:xi="http://www.w3.org/2001/XInclude"/> </section> </appendix> </book>
This results in the second instance being <section id="appendix-id">
, containing the same set of child elements. Since it has a different ID value, it will validate. You can even form a cross reference to either of the instances of the section. Just make sure none of the children have ID values or it will still not validate.
DocBook XSL: The Complete Guide - 3rd Edition | PDF version available | Copyright © 2002-2005 Sagehill Enterprises |