24. DTD for an Attribute with a List of Values

An Enumerated attribute type represents a list (or enumeration) of possible values. Each possible value is required to be a valid XML name. If required, a default value can be assigned. The enumerated attribute type is ideal for setting a possible range of values an attribute can take.

Example 24.1 An Enumerated Attribute Type
<?xml version="1.0" standalone="yes"?>
<!DOCTYPE rootelement [
<!ELEMENT rootelement (childelement1)>
<!ELEMENT childelement (#PCDATA*)>
<!ATTLIST childelement
sampleattribute (enumeration1 | enumeration2) "enumeration1">
]>
<rootelement>
	<childelement sampleattribute="enumeration2">
		Child element.
	</childelement>
	<childelement>
		Child element.
	</childelement>
</rootelement>