Details
-
Bug
-
Status: Open
-
Major
-
Resolution: Unresolved
-
3.0.0, 3.0.1, 3.1.0, 3.1.1, 3.1.2, 3.2.0, 3.1.3, 3.1.4
-
None
-
Windows Visaa 32, Xerces 3.0.1
Description
Validation using the following xsd and xml results in two different results between XercesJ and XercesC++.
For java I get the error reporting the sequence error right after the processing of element <url> because <name>
cannot appear after <url>. But for C++ the error is not reported until the last element within <person> has been
processed. This obviously isn't correct because by that time it is too late. The way Java is reporting it seems to
be correct so that I can stop processing the xml file.
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema'>
<xs:element name="person">
<xs:complexType>
<xs:sequence>
<xs:element name="name" type='xs:string' minOccurs='0' maxOccurs='1'/>
<xs:element name="email" type='xs:string' minOccurs='0' maxOccurs='unbounded'/>
<xs:element name="url" type='xs:string' minOccurs='0' maxOccurs='unbounded'/>
<xs:element name="link" type='xs:string' minOccurs='0' maxOccurs='1'/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
<?xml version="1.0" encoding="UTF-8"?>
<person xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation='foo.xsd'>
<url>www.foo.com</url>
<name>Boss</name>
<email>chief@foo.com</email>
<link/>
</person>
The output from running the XercesJ 2.9.1 Writer sample on the above xsd/xml is:
<person xsi:noNamespaceSchemaLocation="foo.xsd">
<url>www.foo.com</url>
[Error] foo.xml:5:11: cvc-complex-type.2.4.a: Invalid content was found star
ting with element 'name'. One of '
' is expected.
<name>Boss</name>
<email>chief@foo.com</email>
<link></link>
</person>
The output from running the XercesC++ 3.0.1
<?xml version="1.0" encoding="LATIN1"?>
<person xsi:noNamespaceSchemaLocation="foo.xsd">
<url>www.foo.com</url>
<name>Boss</name>
<email>chief@foo.com</email>
<link></link>
Error at file C:\xerces-3_0_1\bin/foo.xml, line 8, char 10
Message: element 'name' is not allowed for content model '((name,email,url),li
nk)'
</person>