You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-dev@xerces.apache.org by Richtnér Fredrik <fr...@wmdata.com> on 2000/08/30 15:44:59 UTC

bug. default value for enum attr doesn't match declared values

I want to report a bug.
Xerces 1.1.3 doesn't report the following attribute declaration as an error.
<!ATTLIST foo	a1 ( a | b | c ) "d">
The default value doesn't match any of the enumerated values for the
attribute.

The error occurs for notation attributes as well.
<!ATTLIST foo	a2 NOTATION ( gif | jpeg ) "tif">

/Fredrik


Re: bug. default value for enum attr doesn't match declared values

Posted by Andy Clark <an...@apache.org>.
Richtnér Fredrik wrote:
> Xerces 1.1.3 doesn't report the following attribute declaration as 
> an error.
> <!ATTLIST foo   a1 ( a | b | c ) "d">
> The default value doesn't match any of the enumerated values for 
> the attribute.

I just looked at the XML Specification and it doesn't state that 
an error should be signaled at the ATTLIST declaration. The actual 
text from the spec says:

  [59] Enumeration ::= '(' S? Nmtoken (S? '|' S? Nmtoken)* S? ')'
                                              [VC: Enumeration]

Where the validity constraint reads:

  Validity constraint: Enumeration
  Values of this type must match one of the Nmtoken tokens in the
  declaration.

The default value is not an attribute value in the DTD -- it
represents what *will* be an attribute value in the instance
document when it is defaulted.

There is some additional text that would, at first glance, lead
you to believe that it should be signaled as an error. Here's
the text:

  Validity constraint: Attribute Default Legal
  The declared default value must meet the lexical constraints
  of the declared attribute type.

The key word here is "lexical". The lexical constraints of the
enumerated values are Nmtoken. And in your sample, "d" *does*
match the lexical constraints. Therefore, it isn't an error.

If you want to fix this to report a warning, please submit the
patch and we'll apply it.

-- 
Andy Clark * IBM, JTC - Silicon Valley * andyc@apache.org