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"
 ......
>

Table of Contents

 About This Book

 Introduction of XML (eXtensible Markup Language)

 XML File Syntax

 XML File Browsers

 XML-JSON Document Conversion

 DOM (Document Object Model) Programming Interface

 SAX (Simple API for XML) Programming Interface

 DTD (Document Type Definition) Introduction

Syntaxes of DTD Statements

 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

 Validating an XML Document against the Specified DTD Document Type

 XSD (XML Schema Definition) Introduction

 Syntaxes of XSD Statements

 Validating XML Documents Against Specified XML Schemas

 XSL (Extensible Stylesheet Language) Introduction

 Java Implementation of XSLT

 XSLT (XSL Transformations) Introduction

 XPath (XML Path) Language

 XSLT Elements as Programming Statements

 Control and Generate XML Element in the Result

 PHP Extensions for XML Manipulation

 Processing XML with Python Scripts

 XML Notepad - XML Editor

 XML Tools Plugin for Notepad++

 XML Plugin Packages for Atom Editor

 XML 1.1 Changes and Parsing Examples

 Archived Tutorials

 References

 Full Version in PDF/EPUB