reference to element under 'all' indicator result with error

Discussion in 'XML' started by Che, Feb 21, 2005.

  1. Che

    Che Guest

    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?
    Che, Feb 21, 2005
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    0
    Views:
    471
  2. Replies:
    2
    Views:
    1,210
    Hendrik Maryns
    Nov 27, 2007
  3. HANM
    Replies:
    2
    Views:
    683
    Joseph Kesselman
    Jan 29, 2008
  4. Austin Bingham
    Replies:
    1
    Views:
    288
    Austin Bingham
    Jan 30, 2010
  5. Michael Tan
    Replies:
    32
    Views:
    908
    Ara.T.Howard
    Jul 21, 2005
Loading...

Share This Page