Attribute Types
In merely well-formed XML, attribute values can be any
string of text. The only restrictions are that any occurrences of
< or & must be escaped as < and &, and whichever kind of quotation
mark, single or double, is used to delimit the value must also be
escaped. However, a DTD allows you to make somewhat stronger
statements about the content of an attribute value. Indeed, these
are stronger statements than can be made about the contents of an
element. For instance, you can say that an attribute value must be
unique within the document, that it must be a legal XML name token,
or that it must be chosen from a fixed list of values.
There are 10 attribute types in XML. They are:
CDATANMTOKENNMTOKENSEnumeration
ENTITYENTITIESIDIDREFIDREFSNOTATION
These are the only attribute types allowed. A DTD cannot say that an attribute value must be an integer or a date between 1966 and 2004, for example.
CDATA
A CDATA attribute
value can contain any string of text acceptable in a well-formed
XML attribute value. This is the most general attribute type. For
example, you would use this type for an alt attribute of an image element because there’s no
particular form the text in such an attribute has to
follow.
<!ATTLIST image alt CDATA #IMPLIED>
You would also use this for other kinds of data such as prices, URLs, email and snail mail addresses, citations, and other types that—while they have more structure than a simple string of text—don’t match any of the other attribute types. ...