DTD - Attribute Declaration (<!ATTLIST>) in DTD
Attribute declaration is used in DTD to define the attributes associated with an XML element. It specifies which attributes an element can have and controls how those attributes are used within an XML document.
The <!ATTLIST> declaration defines the name of the attribute, its data type, and the default or required status. This ensures that attributes follow a fixed structure and format.
DTD allows different attribute types such as CDATA, ID, IDREF, and enumerated values. These types restrict the values an attribute can take, improving data accuracy.
Another important feature of attribute declaration is defining whether an attribute is required (#REQUIRED), optional (#IMPLIED), or has a fixed value (#FIXED). This provides strong control over attribute usage.
DTD also supports default values for attributes. When an attribute is not specified in the XML document, the default value is automatically applied, reducing redundancy.
During XML validation, the parser checks whether attributes match their declarations. Any missing required attribute or invalid value causes a validation error.
Overall, attribute declaration ensures consistency, correctness, and reliability in XML documents by controlling attribute definitions and usage systematically.