As you can see from the syntax above, the ATTLIST declaration defines the
element which can have the attribute, the name of the attribute, the type of the
attribute, and the default attribute value.
The attribute-type can have the following values:
Value
Explanation
CDATA
The value is character data
(eval|eval|..)
The value must be an enumerated value
ID
The value is an unique id
IDREF
The value is the id of another element
IDREFS
The value is a list of other ids
NMTOKEN
The value is a valid XML name
NMTOKENS
The value is a list of valid XML names
ENTITY
The value is an entity
ENTITIES
The value is a list of entities
NOTATION
The value is a name of a notation
xml:
The value is predefined
The attribute-default-value can have the following values:
Value
Explanation
#DEFAULT value
The attribute has a default value
#REQUIRED
The attribute value must be included in the element
In the above example the element square is defined to be an empty element with
the attributes width of type CDATA. The width attribute has a default
value of 0.
Default attribute value
Syntax:
<!ATTLIST element-name attribute-name CDATA "default-value">
DTD example:
<!ATTLIST payment type CDATA "check">
XML example:
<payment type="check">
Specifying a default value for an attribute, assures that the attribute will get
a value even if the author of the XML document didn't include it.
DTD example:
<!ATTLIST sender company CDATA #FIXED "Microsoft">
XML example:
<sender company="Microsoft">
Use a fixed attribute value when you want an attribute to have a fixed value
without allowing the author to change it. If an author includes another value,
the XML parser will return an error.