Attribute Defaults
In addition to providing a data type, each ATTLIST
declaration includes a default declaration for that
attribute. There are four possibilities for this default:
#IMPLIED
The attribute is optional. Each instance of the element may or may not provide a value for the attribute. No default value is provided.
#REQUIRED
The attribute is required. Each instance of the element must provide a value for the attribute. No default value is provided.
#FIXED
The attribute value is constant and immutable. This attribute has the specified value regardless of whether the attribute is explicitly noted on an individual instance of the element. If it is included, though, it must have the specified value.
- Literal
The actual default value is given as a quoted string.
For example, this ATTLIST
declaration says that person
elements can but do not need to have born
and died
attributes:
<!ATTLIST person born CDATA #IMPLIED died CDATA #IMPLIED >
This ATTLIST
declaration
says that every circle
element
must have center_x
, center_y
, and radius
attributes:
<!ATTLIST circle center_x NMTOKEN #REQUIRED center_y NMTOKEN #REQUIRED radius NMTOKEN #REQUIRED >
This ATTLIST
declaration
says that every biography
element
has a version
attribute and that
the value of that attribute is 1.0
, even if the start-tag of the element
does not explicitly include a version
attribute:
<!ATTLIST biography version CDATA #FIXED "1.0">
This ATTLIST
declaration
says that every web_page
element
has a protocol
attribute. If a particular ...
Get XML in a Nutshell, 3rd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.