Table 3.4 Element Type Declarations and Their Meanings




Download 2,96 Mb.
Pdf ko'rish
bet71/131
Sana14.05.2024
Hajmi2,96 Mb.
#232039
1   ...   67   68   69   70   71   72   73   74   ...   131
Bog'liq
Ceponkus, Hoodbhoy - Applied XML - Toolkit for Programmers

Table 3.4 Element Type Declarations and Their Meanings
 
Element Type
Meaning
 
An element called 
Name
must contain 
character data
(that is, text). Under this 
declaration, an allowable element would look 
like this:
Faraz Hoodbhoy
However, under this declaration, the following 
would be unacceptable even though it is well 
formed:
 
Faraz 
Hoodbhoy 

Beep! Parser error. The element type 
declaration must be in CAPITALS.
The loosest declaration possible. An Order 
element can contain any mixture of character 
data and other elements that are 
declared in 
the current DTD
.
main_course,dessert)>
An order 
must
consist of one appetizer, one 
main_course, and one dessert item 
in that 
order
. An acceptable example (though not 
necessarily ahealthy one) would be:
 
Cream of Asparagus 
Soup
 
Fillet 
Mignon
 
Apple Pie ala 
mode
 

Under this order format, you would not be able 
to skip dessert; that is, 
 
Bread rolls with 
butter
 
Fillet 


- 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

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.

Download 2,96 Mb.
1   ...   67   68   69   70   71   72   73   74   ...   131




Download 2,96 Mb.
Pdf ko'rish

Bosh sahifa
Aloqalar

    Bosh sahifa



Table 3.4 Element Type Declarations and Their Meanings

Download 2,96 Mb.
Pdf ko'rish