XML DTD example

This example shows an XML DTD in an XML document and the tree structure form of that document:

<!DOCTYPE test PUBLIC "//this/is/a/URI/test" "test.dtd" [
<!NOTATION TeX  PUBLIC "//this/is/a/URI/TexID" "//TexID">
<!ENTITY ent1 "this is an entity">
<!ENTITY % ent2 "#PCDATA | subel2">
<!ENTITY % extent1 PUBLIC "//this/is/a/URI/extent1" "more.txt">
<!ENTITY extent2 PUBLIC "//this/is/a/URI/extent2" "more.txt">
<!ENTITY unpsd PUBLIC "//this/is/a/URI/me.gif" "me.gif" NDATA TeX>      
<?test Do this?>
<!--this is a comment-->
<!ELEMENT subel2 (#PCDATA)>
<!ELEMENT subel1 (subel2 | el4)+>
<!ELEMENT el1 (#PCDATA)>
<!ELEMENT el2 (#PCDATA | subel2)*>
<!ELEMENT el3 (#PCDATA | subel2)*>
<!ELEMENT el4 (#PCDATA)>
<!ELEMENT el5 (#PCDATA | subel1)*>
<!ELEMENT el6 (#PCDATA)>
<!ATTLIST subel1 
	size (big | small) "big" 
	shape (round | square) #REQUIRED>
<!ATTLIST el5 
	el5satt CDATA #IMPLIED>
]>

When a message is parsed by the generic XML parser, the relevant part of the message tree looks like this (assuming that there are no carriage returns or white space between tags):


Example XML DTD tree structure

The IntSubset structure contains the following structures at the next level of nesting: the tree structure for each of these is shown in the tree structures below.


Example XML IntSubset tree structures (Part 1 of 3)

Example XML IntSubset tree structures (Part 1 of 3)

Example XML IntSubset tree structures (Part 1 of 3)

Example XML IntSubset tree structures (Part 1 of 3)

Example XML IntSubset tree structures (Part 2 of 3)

Example XML IntSubset tree structures (Part 2 of 3)

Example XML IntSubset tree structures (Part 2 of 3)

Example XML IntSubset tree structures (Part 2 of 3)

Example XML IntSubset tree structures (Part 2 of 3)

Example XML IntSubset tree structures (Part 2 of 3)

Example XML IntSubset tree structures (Part 2 of 3)

Example XML IntSubset tree structures (Part 2 of 3)

Example XML IntSubset tree structures (Part 2 of 3)

Example XML IntSubset tree structures (Part 2 of 3)

Example XML IntSubset tree structures (Part 3 of 3)

Example XML IntSubset tree structures (Part 3 of 3)

Example XML IntSubset tree structures (Part 3 of 3)

Example XML IntSubset tree structures (Part 3 of 3)

Example XML IntSubset tree structures (Part 3 of 3)
Related reference
XML document type declaration
XML DocTypeDecl
XML NotationDecl
XML entities
XML ElementDef
XML AttributeList
XML AttributeDef
XML DocTypePI
XML WhiteSpace and DocTypeWhiteSpace
XML DocTypeComment