reference to element under 'all' indicator result with error

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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,999
Messages
2,570,244
Members
46,838
Latest member
KandiceChi

Latest Threads

Top