What does a DTD look like?

A DTD simply defines the nodes of the XML tree, Which parents accept which children, and the attributes associated to each elements.


<!-- Main DTD defining the structure of a presentation -->

<!-- Content elements -->
<!ENTITY % content "image|items|listing">

<!-- The root element -->
<!ELEMENT presentation (title,abstract,page*)>
    <!ELEMENT title (#PCDATA)>
    <!ELEMENT abstract (para*)>
    <!ELEMENT page ((title,abstract?),(para|section|%content;)*)>
        <!ATTLIST page id ID #REQUIRED>
        <!ELEMENT section (title,(para|%content;)*)>
        <!ELEMENT para (#PCDATA|%content;)*>
	<!ELEMENT image EMPTY>
	        <!ATTLIST image name CDATA #REQUIRED>
	<!ELEMENT items (item+)>
		<!ELEMENT item (para+)>
	<!ELEMENT listing (#PCDATA)>

Previous . TOC Next .