You can
easily understand the different parts of an XML DTD with a sample DTD
document. Consider the following sample code in a DTD file.
_______________________________________________
_______________________________________________
<!ELEMENT
books ( book+ ) >
<!ELEMENT book ( title, author+ ) >
<!ATTLIST book category NMTOKEN #REQUIRED >
<!ELEMENT title ( #PCDATA ) >
<!ELEMENT author ( #PCDATA ) >
The ELEMENT
keyword indicates that an element is defined in the document. The word
that follows the keyword is the name of the element.
After the
element the child nodes of that element are given in brackets. A plus
sign by the side of the child node indicates that there could be one
or more child nodes of that name.
There are
different notations to define different patterns like '?' and '*' after
the name of the child node.
The attributes
of an element is defined using the keyword ATTLIST. If that particular
attribute is always required you will be using the keyword #REQUIRED.
The NMTOKEN
in the above examples indicates the type of data that the attribute
holds. An NMTOKEN can hold letters, point, digits, hyphen, underline
and colon. The word #PCDATA indicates that the node can have text data
that is parsed by the parser.