Name

Attribute List Declaration

Synopsis

                        <!ATTLIST 
                        element_name 
                        [attribute_name attribute_type default_decl]
                        *>

In a valid XML document, it is necessary to declare the attribute names, types, and default values that are used with each element type.

The attribute name must obey the rules for XML names, and no duplicate attribute names may exist within a single declaration.

Attributes are declared as having a specific type. Depending on the declared type, a validating XML parser will constrain the values that appear in instances of those attributes within a document. The following table lists the various attribute types and their meanings:

Attribute type

Meaning

CDATA

Simple character data.

ID

A unique ID value within the current XML document. No two ID attribute values within a document can have the same value, and no element can have two attributes of type ID.

IDREF, IDREFS

A single reference to an element ID (IDREF) or a list of IDs (IDREFS), separated by spaces. Every ID token must refer to a valid ID located somewhere within the document that appears as the ID type attribute’s value.

ENTITY, ENTITIES

A single reference to a declared unparsed external entity (ENTITY) or a list of references (ENTITIES), separated by whitespace.

NMTOKEN, NMTOKENS

A single name token value (NMTOKEN) or a list of name tokens (NMTOKENS), separated by spaces.

Get XML in a Nutshell, 3rd 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.