Getting Productive with XMLMind
Pages: 1, 2, 3, 4, 5, 6, 7, 8
Working with Multiple Files and Includes
When working on a really sizeable document, such as a book, you are probably going to want to separate it into multiple files. (O'Reilly sensibly wants each chapter in a separate file, for example.) Although XMLmind can cope with this just fine, we don't yet know of any way to set up the include relationship using the free standard edition, so we always use a plain text editor to do this part.
The best practice is to have the book file just contain the book metadata, and no actual content. All content is attached by inclusion, using the modern XInclude mechanism (see Using XInclude for more details on this standard).
So a simple book file would look something like this:
<?xml version="1.0"?> <!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN" "http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd"> <book> <title>A Small Book Written in XML</title> <xi:include href="copyright.xml" xmlns:xi="http://www.w3.org/2001/XInclude" /> <xi:include href="preface.xml" xmlns:xi="http://www.w3.org/2001/XInclude" /> <xi:include href="setup.xml" xmlns:xi="http://www.w3.org/2001/XInclude" /> <xi:include href="mapping.xml" xmlns:xi="http://www.w3.org/2001/XInclude" /> <xi:include href="whereNext.xml" xmlns:xi="http://www.w3.org/2001/XInclude" /> </book>
Each of the chapter files (such as setup.xml in this example) is a full-fledged XML document with its own headers:
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN" "http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd"> <chapter id="chap-setup"> ... </chapter>
That's one of the things that makes XInclude nice: You can edit each individual file with an XML-aware editor, or you can work with the whole thing as a coherent whole. In XMLmind, when you open the book file, you'll see all of the content that gets included, so you can see what the book as a whole looks like (and how chapters get numbered, etc.), but the included content will be read-only, and displayed with a pastel blue background (you'll get a warning dialog about this, which you can turn off, but it might be a helpful reminder).
When you want to edit any of the included content, simply select part of it or put your insertion point there and choose Edit -> Reference -> Edit Referenced Document (or click the corresponding icon next to the Node path bar):

This will open a new tab editing that specific chapter file, in which you can make your changes. To get back to the book you can either switch tabs or choose Edit -> Reference -> Edit Referencing Document (the next icon to the left).
When you structure a document with XInclude this way, the XML id attributes you assign to sections, figures, and the like are all part of a single global namespace, so you can perform cross-references between chapters with no problem (and XMLmind will help you with this through its ID selection interface as illustrated in Cross References). But this also means you need to be sure to keep your IDs globally unique.
