C
Che
Hi all,
I am working with XSD for a ahile using C# objects (
XmlSchemaCollection , XmlValidatingReader) and have met this problem:
current code demonstrate the problem:
<xs:schema ...>
<xs:element name="Parent" type="Parent_Type" />
<xs:complexType name="Parent_Type">
<xs:all>
<xs:element name="Type" type="xs:string" maxOccurs="1" />
</xs:all>
</xs:complexType>
<xs:complexType name="Child_Type">
<xs:complexContent>
<xs:extension base="Parent_Type"/>
</xs:complexContent>
</xs:complexType>
<xs:element name="Child" substitutionGroup="Parent" type="Child_Type"
/>
<xs:element name="Test">
<xs:complexType>
<xs:all>
<xs:element ref="Parent" minOccurs="0" />
<xs:element name="additionalElement" type="xs:boolean" />
</xs:all>
</xs:complexType>
</xs:element>
</xs:schema>
When loading the XSD to a XmlSchemaCollection object I get the
exception: System.InvalidCastException.
The most weird thing is that when I change the indicator to be
<xs:sequence> - it works fine (!)
And when I remove the object 'Child' it also works fine (!!!)
If I remove the 'additionalElement' it also works fine (!!!!!!)
What is wrong here? Could it be a bug?
I am working with XSD for a ahile using C# objects (
XmlSchemaCollection , XmlValidatingReader) and have met this problem:
current code demonstrate the problem:
<xs:schema ...>
<xs:element name="Parent" type="Parent_Type" />
<xs:complexType name="Parent_Type">
<xs:all>
<xs:element name="Type" type="xs:string" maxOccurs="1" />
</xs:all>
</xs:complexType>
<xs:complexType name="Child_Type">
<xs:complexContent>
<xs:extension base="Parent_Type"/>
</xs:complexContent>
</xs:complexType>
<xs:element name="Child" substitutionGroup="Parent" type="Child_Type"
/>
<xs:element name="Test">
<xs:complexType>
<xs:all>
<xs:element ref="Parent" minOccurs="0" />
<xs:element name="additionalElement" type="xs:boolean" />
</xs:all>
</xs:complexType>
</xs:element>
</xs:schema>
When loading the XSD to a XmlSchemaCollection object I get the
exception: System.InvalidCastException.
The most weird thing is that when I change the indicator to be
<xs:sequence> - it works fine (!)
And when I remove the object 'Child' it also works fine (!!!)
If I remove the 'additionalElement' it also works fine (!!!!!!)
What is wrong here? Could it be a bug?