According to textbooks, DTDs are strange creatures. Let's use a simple example to describe. Take the following:
<!DOCTYPE letter [
<!ELEMENT letter (to, from, subject, message)>
<!ELEMENT to (#PCDATA)>
<!ELEMENT from (#PCDATA)>
<!ELEMENT subject (#PCDATA)>
<!ELEMENT message (#PCDATA)>
The first line declares that this is a DTD for
XML documents with the root element letter.
The letter-element is declared as
consisting of four elements. These elements
must appear
in the order described in the comma separated list
<!ELEMENT letter (to, from, subject, message)>
The parentheses hold the rules for the content, the order, and the number of each element allowed by the DTD. In the list of elements parentheses may be inserted to create groups of occurences. Special characters reminiscing wild card characters from regular expressions in UNIX or programming languages are used to define number of occurences of individual elements or groups of elements. the following table illuminates the use of the special characters and their meaning:
| ? |
None or one |
| + |
One or more |
| * |
Zero or more |
| | |
End |
| () |
Parentheses define groups of elements.
Here |
Look at the possibilities:
<!ELEMENT group (projectmanager, member, menber+)><!ELEMENT class ((group, member+)+)><!ELEMENT project (task|#PCDATA)><!ELEMENT table (tr, tr)><!ELEMENT tr (td+)>