XML.com: XML From the Inside Out
oreilly.comSafari Bookshelf.Conferences.

advertisement

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):

figure

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.

Comments

Sometimes you just want to leave a note for yourself or your coauthors in the document. XMLmind supports that, leveraging the normal comment syntax of XML. The Edit menu has a Comment submenu that you can use to insert a comment at, before, or after the node you're currently working on. (If the choices are grayed out, you probably have a range of text selected within a #text node; either just click to get back to an insertion point, or use the Node path to select a specific entity with which you want to associate the comment.)

Within XMLmind, the comment will show up with a pastel yellow background (as if someone used a highlighter pen on it). Most stylesheets will simply not display the comments at all, so you don't need to worry about them showing up in your final copy. The O'Reilly stylesheets used for producing author drafts display the comments in bright red to help us find areas of our books that still need attention.

Miscellany

Here are some other things that are worthy of your investigation, although we're not going to take the time to cover them in as much depth.

Be sure to explore the Character tool(another tab in the lower-right interface that includes the Attribute tool we've been discussing):

figure

It's the first cross-platform place we've seen something that comes close to Mac OS X's convenient character palette for exploring the Unicode space and selecting the right special symbol you need to insert into your document. You can also use your platform-normal keyboard equivalents for special characters you happen to know, but there are way more useful symbols in the Unicode space than you can access from any keyboard. Just click one of the characters in the table to insert it into your document in a cross-platform, XML-safe way.

Also found in this set of tabbed panes are a spelling checker (the Spell tool), text find-and-replace system (the Search tool) and validation error list. The Attributes tool itself has more features than we've covered for viewing and editing the XML attributes of the currently-selected document node. And if you want to learn a bit more about the legal structure of the selected node itself, you can choose Show Content Model from the Help menu.

If you find better ways of doing anything we've talked about, or anything cool we simply didn't mention at all, please let us know! We're well aware there's a lot more to discover and share about this excellent tool.

Feel free to download the source DocBook XML version of this article, along with its figs directory, if you'd find it useful as an example of anything we've discussed here, or as a starting point for your own work.



1 to 3 of 3
  1. Los Angeles Locksmith 323-678-2704
    2010-06-16 12:26:52 carpetcare
  2. More useful tips
    2007-06-26 13:54:46 James_Elliott
  3. Additional Elements
    2007-06-22 18:36:26 Susan Jolly
1 to 3 of 3