XML technologies / XML / XML in a Nutshell / Document type definitions (DTDs) / Conditional inclusion
(Excerpt from "XML in a Nutshell" by Elliotte Rusty Harold & W. Scott Means)
XML provides the directive IGNORE, to comment out a section of declarations. For example, a parser ignores the following declaration of an element produktionshinweis as if it were not present in the DTD:
<![IGNORE [<!ELEMENT produktionshinweis (#PCDATA)>]]>This may not seem particularly useful. After all, you could simply use an XML comment to disable declarations temporarily. If you think so, the directive INCLUDE may seem even less useful. Its purpose is to indicate that the declarations really are to be used in the DTD. For example:
<![INCLUDE [<!ELEMENT produktionshinweis (#PCDATA)>]]>The effect and meaning of these lines are exactly the same as if the directive INCLUDE were absent. Now consider what happens if INCLUDE and IGNORE were not used directly. Instead, suppose we define a parameter entity as follows:
<!ENTITY % erlaubte_hinweise "INCLUDE"> We then use a parameter entity instead of the keyword:
<![%erlaubte_hinweise;[<!ELEMENT produktionshinweis (#PCDATA)>]]>The parameter entity erlaubte_hinweise can be redefined from outside this DTD, particularly in a document’s internal DTD subset. This provides a switch allowing individual documents to enable or disable the declaration produktionshinweis. This technique lets document authors select only the DTD functionality they need.
Copyright © 2005 O'Reilly Verlag GmbH & Co. KG
You may print the online version for your private use.
Otherwise, this chapter from the book "XML in a Nutshell" is subject to the same conditions as the printed edition: the work and all its parts are protected by copyright. All rights reserved, including reproduction, translation, microfilming, and storage and processing in electronic systems.
O’Reilly Verlag GmbH & Co. KG, Balthasarstraße 81, 50670 Köln, kommentar(at)oreilly.de
back to top