Validator incorrectly rejects XML
---------------------------------
Key: XERCESC-1610
URL: http://issues.apache.org/jira/browse/XERCESC-1610
Project: Xerces-C++
Type: Bug
Components: Validating Parser (Schema) (Xerces 1.5 or up only)
Versions: 2.7.0
Environment: Linux (Debian Etch)
Reporter: Edsko de Vries
Consider the following XML schema:
<?xml version="1.0"?>
<xs:schema
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns="http://testcase"
targetNamespace="http://testcase"
elementFormDefault="qualified">
<xs:element name="root">
<xs:complexType>
<xs:sequence>
<xs:element name="a" type="xs:string"/>
<xs:element name="a" type="xs:string" nillable="true"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
And the following XML test instance:<?xml version="1.0"?>
<root xmlns="http://testcase"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://testcase schema.xsd">
<a>a</a>
<a xsi:nil="true" />
</root>
This yields the following (incorrect) error:
Error at file test.xml, line 4, char 22
Message: xsi:nil must not be specified for the element a with nillable equals
false
Interestingly, when the schema (and the instance document) is modified so that
the two tags are reversed:
...
<xs:element name="a" type="xs:string" nillable="true"/>
<xs:element name="a" type="xs:string"/>
...
the document _does_ validate fine. However, with this schema, when the instance
document is modified to
<?xml version="1.0"?>
<root xmlns="http://testcase"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://testcase schema.xsd">
<a xsi:nil="true" />
<a xsi:nil="true" />
</root>
the document _still_ validates! (whereas of course it should no longer
validate).
Guess: It appears the nillability of <a> is stored the first time an <a> is
encountered; so, when the first <a> is not nillable, Xerces thinks that all
<a>s must not be nillable, but when the first <a> is nillable, it thinks all
<a> may be nillable.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]