Declaring Attributes

Just as the element declaration limits the contents of a particular element, the attribute declaration controls which and what type of attributes can be included in a particular element.

The <!ATTLIST> markup tag is used to control the attributes that can be included in a particular element. As an example, here's the attribute declaration for the item element:

<!ATTLIST item
  id  ID    #IMPLIED
  ref IDREF #IMPLIED
>

The first name token after the <!ATTLIST> markup is the name of the element associated with this declaration. Following the element name is a list of attribute name, type, and default-value triples. Multiple <!ATTLIST> declarations can be given for a single element throughout the DTD. The result is the same as if ...

Get Strategic 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.