Stylus Studio XML Editor

Table of contents

Appendices

3.4 Conditional Sections

Conditional Sections

Conditional sections are portions of the Document Type Declaration or of external parameter entities which are included in, or excluded from, the logical structure of the DTD based on the keyword which governs them.

Conditional Section
3.4    conditionalSect   ::=   includeSect | ignoreSect
3.4    includeSect   ::=   '<![' S? 'INCLUDE' S? '[' extSubsetDecl ']]>' [VC: Proper Conditional Section/PE Nesting]
3.4    ignoreSect   ::=   '<![' S? 'IGNORE' S? '[' ignoreSectContents* ']]>'[VC: Proper Conditional Section/PE Nesting]
3.4    ignoreSectContents   ::=   Ignore ('<![' ignoreSectContents ']]>' Ignore)*
3.4    Ignore   ::=   Char* - (Char* ('<![' | ']]>') Char*)

Validity Constraint: Proper Conditional Section/PE Nesting

Proper Conditional Section/PE Nesting

If any of the "<![", "[", or "]]>" of a conditional section is contained in the replacement text for a parameter-entity reference, all of them MUST be contained in the same replacement text.

Like the internal and external DTD subsets, a conditional section may contain one or more complete declarations, comments, processing instructions, or nested conditional sections, intermingled with white space.

If the keyword of the conditional section is INCLUDE, then the contents of the conditional section MUST be considered part of the DTD. If the keyword of the conditional section is IGNORE, then the contents of the conditional section MUST be considered as not logically part of the DTD. If a conditional section with a keyword of INCLUDE occurs within a larger conditional section with a keyword of IGNORE, both the outer and the inner conditional sections MUST be ignored. The contents of an ignored conditional section MUST be parsed by ignoring all characters after the "[" following the keyword, except conditional section starts "<![" and ends "]]>", until the matching conditional section end is found. Parameter entity references MUST NOT be recognized in this process.

If the keyword of the conditional section is a parameter-entity reference, the parameter entity MUST be replaced by its content before the processor decides whether to include or ignore the conditional section.

An example:

<!ENTITY % draft 'INCLUDE' >
<!ENTITY % final 'IGNORE' >
<![%draft;[
<!ELEMENT book (comments*, title, body, supplements?)>
]]>
<![%final;[
<!ELEMENT book (title, body, supplements?)>
]]>