- 68 -
Mignon
would be unacceptable. Nor would you be able
to
order food out of sequence; that is,
Apple Pie ala
mode
Bread rolls with
butter
Fillet
Mignon
would also be disallowed by the parser.
main_course?,dessert?)>
An order
may
consist
only
of one appetizer,
one main_course, and/or one dessert item
in
that order
.
For example:
Bread rolls with
butter
Fillet
Mignon
is acceptable to the parser, while
Apple Pie ala
mode
Bread rolls with
butter
is unacceptable because the order of
occurrence
of the elements is contrary to what
was specified.
cream|Coffee)>
Dessert elements consists of either a
single
ice-cream element
or
a
single
coffee element.
For example:
vanilla
is a valid Dessert element while
Apple
is not. It is well formed
but not valid under this
- 69 -
element type declaration.
(vanilla|chocolate|
strawberry)+>
An ice-cream element consists of
at least
one
or more
vanilla, chocolate, or strawberry
elements.
For example:
...
...
...
is valid while
is not.
(vanilla|chocolate|
strawberry)*>
An ice-cream element consists of
at least zero
or more
vanilla, chocolate, or strawberry
elements.
For example:
...
...
...
is valid and so is.
(#PCDATA|menu_item)*>
This notation is used
for elements with mixed
content, that is, character data and further
elements. In
this case, an order element can
consist of a mixture of at least zero or more
character data and menu elements in any
order.
For example:
Madame will have:
Cream of asparagus
soup
Sweet
Potatoes
Apple Pie
Used for elements that do not contain content.
In this case, the cupboard element contains
nothing.
- 70 -
Descriptions of Element Type Content Models
If you’ve skimmed over Table 3.4, you have an idea of what we’re talking about. This
section is more of a reference section in case there is something specific you didn’t find
in the table or want further clarification.
Describing the content model is key to defining the structure of your XML document. We
wish there was an easier way to do it than to use the unintuitive DTD syntax, but for now
we’re all stuck with it. The content model essentially tells the parser what an element can
contain. For example, you might want an element
to be made of text only, such as:
...
Perhaps you want it to be made of other elements:
...
...
Perhaps still further, you want a mixture of both (technical name:
mixed content
):
Some text that adds further information
...
...
There are so many ways of representing information that we make no pretensions about
the best way of structuring your information. You’re not going to get away from creating
those pesky tree diagrams and story boards of your data—sorry. What you will find below
are several common scenarios that should be able to help you create your own DTDs for
enforcing whatever structure it is that you finally do decide upon.