SYMPTOMS
The current implementation of XSD schema-validation support
in the .NET framework does not convert the targerNamespace of the local
referencing type of an included XSD (it does not support the "chameleon"
include). For example, the following a.xsd file includes the b.xsd and c.xsd
files:
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="test">
<xsd:include schemaLocation="b.xsd" />
<xsd:include schemaLocation="c.xsd" />
</xsd:schema>
Inside b.xsd, a testType type is defined:
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:simpleType name="testType">
<xsd:restriction base="xsd:string">
<xsd:enumeration value="test"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:schema>
Inside c.xsd, test is declared with the testType type:
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="test" type="testType"/> <!-- this fails, but it should not fail -->
</xsd:schema>
The following error message is returned with the a.xsd schema file:
"Type 'testType' is not declared." in c.xsd
RESOLUTION
To work around this problem, add a xmlns="test" namespace
declaration to the c.xsd file, for example:
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="test">
<xsd:element name="test" type="testType" xmlns="test"/>
</xsd:schema>