Corrections to Chapter 11 of The XML Bible, Embedding Non-XML Data

p. 319: There's a [ missing from the first line of all the IGNORE and INCLUDE sections on this page. For instance, the first code fragment should be:

<![ IGNORE [
  declarations that are ignored
]]>

instead of

<![ IGNORE 
  declarations that are ignored
]]>
The entire page should read:

Conditional Sections in DTDs

When developing DTDs or documents, you may need to comment out parts of the DTD not yet reflected in the documents. In addition to using comments directly, you can omit a particular group of declarations in the DTD by wrapping it in an IGNORE directive. The syntax follows:

<![ IGNORE [
  declarations that are ignored
]]>

As usual, white space doesn't really affect the syntax, but you should keep the opening <![ IGNORE [ and the closing ]]> on separate lines for easy viewing.

You can ignore any declaration or combination of declarations ‹ elements, entities, attributes, or even other IGNORE blocks ‹ but you must ignore entire declarations. The IGNORE construct must completely enclose the entire declarations it removes from the DTD. You cannot ignore a piece of a declaration (such as the NDATA GIF in an unparsed entity declaration).

You can also specify that a particular section of declarations is included ‹ that is, not ignored. The syntax for the INCLUDE directive is just like the IGNORE directive but with a different keyword:

<![ INCLUDE [
  declarations that are included
]]>

When an INCLUDE is inside an IGNORE, the INCLUDE and its declarations are ignored. When an IGNORE is inside an INCLUDE, the declarations inside the IGNORE are still ignored. In other words, an INCLUDE never overrides an IGNORE.

Given these conditions, you may wonder why INCLUDE even exists. No DTD would change if all INCLUDE blocks were simply removed, leaving only their contents. INCLUDE appears to be completely extraneous. However, there is one neat trick with parameter entity references and both IGNORE and INCLUDE that you can't do with IGNORE alone. First, define a parameter entity reference as follows:

<!ENTITY % fulldtd "IGNORE">

You can ignore elements by wrapping them in the following construct:

<![ %fulldtd; [
  declarations
]]>

[ Cafe con Leche | Order from amazon.com | The XML Bible Home Page | Table of Contents | Updated Chapters | Examples | Errata from other Chapters ]

Copyright 2000 Elliotte Rusty Harold
elharo@metalab.unc.edu
Last Modified March 16, 2000