|
| |
The operators and keywords available for specifying elements (tags) are:
| Operator/Keyword |
Meaning |
| | |
OR operator |
| () |
Content grouping |
| ? |
Preceding item may occur zero or one time |
| + |
Preceding item may occur one or more times |
| * |
Preceding item may occur zero or more times |
| #PCDATA |
Element may contain only parsed character data, but no child elements of
any type. |
| EMPTY |
Element may not contain content |
| ANY |
Element may contain any content defined in the DTD |
For example:
<?xml version = "1.0" encoding = "utf-8"?>
<!DOCTYPE memo [
<!ELEMENT memo (from, to+, body, priority?)>
<!ELEMENT from (#PCDATA)>
<!ELEMENT to (name | department)>
<!ELEMENT name (#PCDATA)>
<!ELEMENT department (#PCDATA)>
<!ELEMENT body (#PCDATA)>
<!ELEMENT priority (high | medium | low)>
<!ELEMENT high EMPTY>
<!ELEMENT medium EMPTY>
<!ELEMENT low EMPTY>
]>
<memo>
<from>College President</from>
<to>
<name>Faculty</name>
</to>
<to>
<name>Students</name>
</to>
<to>
<department>Computer Science</department>
</to>
<body>
Here is a very important message for all members of the
College community. Blah, blah, blah...
</body>
<priority><high></high></priority>
</memo>
The above is a well-formed, valid XML document, based on
its DTD. To see how your browser renders the above XML, click here. In
general, an element type declaration looks like:
<!ELEMENT element-name content>
where:
- element-name is any correct XML name
- content may contain one of the following:
EMPTY -- no content is allowed in the element
ANY -- the element is allowed to have any element
or character data as its content, in any order.
(#PCDATA) -- the element is only allowed to have
character data content.
- "Mixed content" -- character data may be intermingled
with child elements. For example:
(#PCDATA | plain | bold | italic)
- "Child elements only" -- only child elements
specified may appear as content for the element. For example:
(a, b, c)
(a | b | c)
( (a | b), c, d, (e, f) )
( introduction, section+, summary, references?)
|