Aggregating Modifiers to Allow Any Order and Any Number in DTDs

The Choice modifier specifies that only one of the specified elements can appear in an instance document. However, if you specify the Zero or More modifier and then the Choice modifier, the result is that the specified elements can appear in any order and each element can appear any number of times.

The text for such an element definition is as follows:

<!ELEMENT A (B|C|D)*>
               

            

The tree representation is as follows:

A
               

              
Zero or More
                   
Choice
                   
	B
                   
	C
                   
	D
                   

                

This allows an A element to contain

  • Zero, one, or more B elements
  • Zero, one, or more C elements
  • Zero, one, or more D elements

Furthermore, the contained elements can be in any order.

 
Free Stylus Studio XML Training:
W3C Member