- 71 -
Scenario: Specifying an Element That Can Contain “Any” Elements
and Character Data
The ANY content model descriptor is the most loosely defined way of describing an
element. ANY implies that the element can be an undefined
mixture of elements that
have been declared in the DTD as well as character data.
The Element Type Declaration for an element called catch_all is:
A word of caution when using the ANY descriptor: Elements that inherit their complete
characteristics can not be overridden by an undefined element. If you include a flavors
element that has been previously defined to contain
a choice of vanilla, chocolate, or
strawberry, you can not override the flavors definition by putting in an unspecified flavor
element, for example cookie_crumble.
Scenario: Specifying a Single Element That Contains Character Data
This is probably one of the most common declarations you will be using. This type of
element simply has a name and can contain PCDATA (that is, text only). Here’s the
Element Type Declaration:
Once declared in your DTD, any
name
element in your XML
document would look like
this:
Faraz Hoodbhoy
Under this type definition,
name
elements cannot contain subelements, for example:
Faraz
Hoodbhoy
is not allowed by the parser.