Element Declarations in DTDs

With an understanding of what valid XML is, and why we might want to take advantage of it, it's time to take a look at the physical constructs that make up a DTD. Let's go back to our first simple DTD example:

<!-- A Simple DTD --> 
<!ELEMENT inventory (item+)>
<!ELEMENT item (description, sku)>
<!ELEMENT description (#PCDATA)>
<!ELEMENT sku (#PCDATA)>

This example is actually a complete and valid DTD. You will notice that unlike with XML, there is no prolog or any formal structure that identifies this as a DTD. We have added a comment line that identifies it, but there are no formal requirements or headers for DTDs.

The DTD itself will consist of a series of declarations, and the first declaration we're going to ...

Get Special Edition Using XML, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.