Next Up Previous Contents
Next: B Support utilities
Up: A.5 Marked sections
Previous: A.5 Marked sections
[ID index][Keyword index]

A.5.1 IGNORE and INCLUDE marked sections

About the only use of the IGNORE and INCLUDE marked sections in documents is to delimit variant sections of text (see Section 3.5.2). They are, however, very common within DTDs.

Why on earth would you want to include or exclude text in DTDs? Because the IGNORE/INCLUDE keyword can be the expansion of an entity. We could have defined our HTML-like document type as follows:

<!ENTITY % allow.copyright "IGNORE">
<![ %allow.copyright; [
  <!ENTITY % html.model "head, body, copyright?">
  <!ELEMENT copyright - - (#PCDATA)>
]]>
<!ENTITY % html.model "head, body">
<!ELEMENT html    O O (%html.model;)>
This looks very strange, but it is a common idiom.

The entity reference %allow.copyright; is a `parameter entity reference' (see section Appendix A.4), which is distinct from a general entity reference such as &amp;, and can occur only within markup (ie, within DTDs).

The parameter entity %allow.copyright is defined to be IGNORE. That means that when the parser finds the marked section it ignores it, so that the first definition it finds of the parameter entity %html.model is the one which sets it to be `head,body', so that is what is used as the content model in the declaration of the html element in the last line.

Nothing appears to have been achieved here. However, if the %allow.copyright entity had earlier been set to INCLUDE, then the redefinition of it here would have been ignored, the marked section would have been included, the %html.model entity would have been defined as `head,body,copyright?' with the (now) second one ignored, and the html element would have been defined to allow all three elements. That is, marked sections used internally in this way can be a useful way of parameterising DTDs.

The entity could be declared earlier in the same DTD, in a particular document's DTD-subset (see Section 3.3), or completely externally to the document in a command-line option to the parser.


Next Up Previous Contents
Next: B Support utilities
Up: A.5 Marked sections
Previous: A.5 Marked sections
[ID index][Keyword index]
The Starlink SGML Set
Starlink System Note 70
Norman Gray, Mark Taylor
21 April 1999. Release DR-0.7-13. Last updated 24 August 2001