Document type definitions
If an element is not qualified with one of these symbols, then the element can appear once and only once. Consequently, in the example above, since pets is defined to contain the element pet, and the pet element is qualified with a plus sign, there must be at least one pet element within the pets element.
There is another value for element definitions you need to know, #PCDATA. This stands for parsed character data, and it is used to denote content that contains only text, text without markup.
Finally, it is entirely possible that an element will contain multiple, sub elements. When strung together, this list of multiple elements is called a sequence, and they can be grouped together in the following ways:
comma (,) is used to denote the expected order of the elements in the XML file
parentheses (()) are used to group elements together
vertical bar (|) is used to denote a Boolean union relationship between the elements.
Putting it all together
Walking through the DTD for pets.xml we see that:
The root element of the document should is pets.
The root element, pets, contains at least one pet element.
Each pet element can contain one and only one name, age, type, and color element, in that order.
The elements name, age, type, and color are to contain plain text, no mark up.
Below is a DTD for the letter in a previous example.
_ (date, addressee, greeting, (paragraph+ | list+)* (#PCDATA)> (name, address one, address two)> (#PCDATA)> (#PCDATA)> (#PCDATA)> (#PCDATA)> (#PCDATA | italics)*> (#PCDATA)> (item+)> (#PCDATA)> (#PCDATA)> _
This example is a bit more complicated. Walking through it we see that: