XML Tutorials - Herong's Tutorial Notes
Dr. Herong Yang, Version 4.00

ATTLIST - Attribute List Declaration Statement

This section describes syntax formats of the ATTLIST statement, which is used to declare a list of attributes for the specified element. The ATTLIST statement specifies what is the name of the attribute, what is the data type, and what is the default value.

ATTLIST: is a DTD statement that defines one or more attributes of an XML element. The ATTLIST statement specifies what is the name of an attribute, what is the data type of the attribute value, whether the attribute is required, and what is the default attribute value.

The syntax of ATTLIST statement is:

<!ATTLIST element_name
 attribute_name value_type default_value
 attribute_name value_type default_value
 ......
>

"value_type" specifies what data type is allowed for the value of this attribute. The most commonly used values types are:

1. Character Data: The attribute value can be a string of any regular characters.

<!ATTLIST element_name
 attribute_name CDATA default_value
 ......
>

2. List of String Values: The attribute value can be any string value in the list. List of string values is declared by:

<!ATTLIST element_name
 attribute_name (value_1 | value_2 | ...) default_value
 ......
>

Note that string values should be entered without quotes.

"default_value" specifies whether this attribute is required or not, what is the default value. There are 4 ways to specify a default value:

1. Required: The attribute is required.

<!ATTLIST element_name
 attribute_name value_type #REQUIRED
 ......
>

2. Implied: The attribute is optional.

<!ATTLIST element_name
 attribute_name value_type #IMPLIED
 ......
>

3. Fixed: The attribute has a fixed value, and the value is specified in the declaration statement. If this attribute is included in the XML file, it must have the specified value. If this attribute is not included in the XML file, the XML parser will provide it with the specified value.

<!ATTLIST element_name
 attribute_name value_type #FIXED "value"
 ......
>

4. Default: A default value is specified for the attribute. If this attribute is not included in the XML file, the XML parser will provide it with the specified default value. If this attribute is included in the XML file, the specified default value will be replaced by the specified default value.

<!ATTLIST element_name
 attribute_name value_type "value"
 ......
>

Sections in This Chapter

DOCTYPE - Document Type Declaration Statement

ELEMENT - Element Declaration Statement

ATTLIST - Attribute List Declaration Statement

ENTITY - Entity Declaration Statement

dictionary_dtd.xml - XML DTD Document Type Example

Dr. Herong Yang, updated in 2009
ATTLIST - Attribute List Declaration Statement