- 87 -
An implied default is one that doesn’t have to be explicitly defined: The parser is told to
pass on a blank value to the XML application and let it decide what to do next. In doing
so, you give yourself as an application developer more flexibility (and responsibility).
Here’s how you assign an implied default to an attribute.
#IMPLIED
>
Essentially, we’ve told the parser that a person element has a gender attribute of type
CDATA and that no value is supplied; therefore, let the XML application decide what to
do next (for example, issue an error or toss in a default value). Thus, although the parser
doesn’t mark it as an error, the XML application can if the developer wants it to.
Fixed Attribute Values
Attributes with fixed defaults completely define an attribute and do not allow any changes
to the attributes values in the XML document. If the attribute value in the XML document
is left blank, the parser passes the specified default value to the parser. If the attribute
has a value other than that specified, the parser reports an error. Finally, if the attribute
value in the document matches the specified value, no error is detected, and the
specified value is passed on to the application.
Here’s how to fix an attribute:
#FIXED
"Happy">
This tells the parser that by default every person element’s mood attribute
must
be Happy
(wouldn’t that be great!) Thus, there are two possible ways of representing the person
element:
or
In both cases, the XML parser tells the XML application the same thing—that the person
element’s mood attribute value is happy.