is it possible to use xs:union for complexTypes?

Viewed 5258

<xs:element name="Kunde" type="tKunde"/>


<xs:complexType name="tKunde">
    <xs:union memberTypes="tPerson tStudent"></xs:union>
</xs:complexType>
<xs:complexType name="tPerson">
    <xs:sequence>
        <xs:element name="Vorname" type="xs:string"/>
        <xs:element name="Nachname" type="xs:string"/>
    </xs:sequence>
</xs:complexType>

<xs:complexType name="tStudent">
    <xs:complexContent>
        <xs:extension base="tPerson">
        <xs:sequence>
            <xs:element name="Matrikelnummer" type="xs:int" minOccurs="0" maxOccurs="1"/>
        </xs:sequence>
        </xs:extension>
    </xs:complexContent>
</xs:complexType>

Thats what it should look like. The task is to derive a Student from Person and then make it possible to use one of the two types for the element Kunde.

This seems to be invalid.

1 Answers
Related