| Advertise Here |
|
DTD - AttributesDeclaring AttributesIn the DTD, XML element attributes are declared with an ATTLIST declaration. An attribute declaration has the following syntax:
As you can see from the syntax above, the ATTLIST declaration defines the element which can have the attribute, the name of the attribute, the type of the attribute, and the default attribute value. The attribute-type can have the following values:
The attribute-default-value can have the following values:
Attribute declaration example
In the above example the element square is defined to be an empty element with the attributes width of type CDATA. The width attribute has a default value of 0. Default attribute value
Specifying a default value for an attribute, assures that the attribute will get a value even if the author of the XML document didn't include it. Implied attribute
Use an implied attribute if you don't want to force the author to include an attribute and you don't have an option for a default value either. Required attribute
Use a required attribute if you don't have an option for a default value, but still want to force the attribute to be present. Fixed attribute value
Use a fixed attribute value when you want an attribute to have a fixed value without allowing the author to change it. If an author includes another value, the XML parser will return an error. Enumerated attribute values
Use enumerated attribute values when you want the attribute values to be one of a fixed set of legal values. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Jump to : Top Of Page or HOME |