XML Conditional DTD Sections

Conditional sections of a DTD are defined using the <![INCLUDE[ ]]> tag to include the section or <![IGNORE[ ]]> to exclude the section.

The format of conditional sections in a DTD is as follows:

<![Keyword[DTDDeclarations] ]>

  • Keyword—one of INCLUDE or IGNORE
  • DTDDeclarations—any valid DTD declarations or definitions

Description

Conditional sections are typically declared using parameter entities, and then referenced in other declarations. For example:

<!ENTITY % draft "IGNORE">
<![%draft;[
   <!ELEMENT summary (comments*,title,shortdesc)>
]]>

XML Structs

XML-based Structs contain no members representing conditional DTD sections.

When using xmlToStruct/full to create an XML-based Struct:

  • If the XML document refers to an external DTD, Struct members representing this DTD are only generated if /validate is also used.
  • DTD struct members are created for any declarations found within an<![INCLUDE[ ... ]]> tag, and they will come before the ones for an external DTD.
  • No Struct members are generated for DTD sections that have been excluded using <![IGNORE[ ... ]]>.

Conditional Sections

In the following example, an external DTD specifies different contents for draft and release (the comments element is not present in release) .

<!ENTITY % draft "IGNORE">
<!ENTITY % release "INCLUDE">
<![%draft;[
   <!ELEMENT summary (comments*,title,shortdesc)>
]]>
<!%[release;[
   <!ELEMENT summary (title,shortdesc)>
]]>
<!ELEMENT comments (#PCDATA)>
<!ELEMENT title (#PCDATA)>
<!ELEMENT shortdesc (#PCDATA)>