Hi Umesh,
the XML file is also referencing a schema for the foo namespace
(xsi:schemaLocation="foo particlesB013_1.xsd"); if by chance this
schema really exists, then b is defined and valid. I tried removing
the schemaLocation attribute and I got the expected "Unknown element
'b'" error.
Alberto
At 18.59 18/07/2007 +0530, Umesh Chandak wrote:
Hi All,
I am using the loadGrammar function for validating xml instances
against xml schema. But According to me instance is invalid but xerces
says it is valid.
*******************************XSD FILE ************************
<?xml version="1.0"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="doc">
<xsd:complexType>
<xsd:choice>
<xsd:element name="elem" type="elem"/>
</xsd:choice>
</xsd:complexType>
</xsd:element>
<xsd:complexType name="elem">
<xsd:choice>
<xsd:any maxOccurs="2"/>
</xsd:choice>
</xsd:complexType>
</xsd:schema>
****************************************************************
**************************XML FILE *****************************
<?xml version="1.0"?>
<doc xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="particlesB013.xsd"
xsi:schemaLocation="foo particlesB013_1.xsd">
<elem>
<b xmlns="foo"/>
</elem>
</doc>
*****************************************************************
According to me this instance is invalid because element 'b' which falls
in 'any' wildcard group with processContent = strict because by default
processContent is strict. But there is no declaration of element 'b' is
available in XSD file.
Please let me know why Xerces is saying valid instance to this. This
example is from MicroSoft's MSSchemaTestSuite test suite.
Thanks.
Regards,
Umesh