Thursday, 19 September 2013

DTD - attributes with fixed default values

DTD - attributes with fixed default values

Lets say I have a snippet of a DTD declaration like this.
<!ELEMENT book ANY>
<!ATTLIST book genre #FIXED "fantasy">
Note that the genre attribute was declared with a fixed default value of
fantasy.
What exactly is the meaning of such a declaration? Two possible
interpretations come to mind:
A document is not valid unless each book element contain a genre attribute
with value fantasy.
A document is valid if each book element either contains a genre attribute
with value fantasy or does not contain the genre attribute at all.
I did not find a definitive answer in the DTD specification, even though
the second one seems more likely because of the following part:
Validity constraint: Fixed Attribute Default
If an attribute has a default value declared with the #FIXED keyword,
instances of that attribute MUST match the default value.

No comments:

Post a Comment