Element Declarations

To declare the syntax of an element in a DTD, you use the <!ELEMENT> element like this: <!ELEMENT NAME CONTENT_MODEL>. Here, NAME is the name of the element you're declaring; CONTENT_MODEL can be set to EMPTY or ANY, or it can hold mixed content (other elements as well as parsed character data) or child elements.

Here are a few element examples—note the expressions starting with % and ending with ;. Those expressions are parameter entity references, much like general entity references, except that you use them in DTDs, not the body of the document (we'll see parameter entities in the next chapter):

 <!ELEMENT direction (left, right, top?)> <!ELEMENT CHAPTER (INTRODUCTION, (P | QUOTE | NOTE)*, DIV*)> <!ELEMENT HR EMPTY> <!ELEMENT ...

Get Real World XML 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.