开发者

is it possible to use xs:union for complexTypes?

开发者 https://www.devze.com 2023-03-16 08:11 出处:网络
<xs:element name=\"Kunde\" type=\"tKunde\"/> <xs:complexType name=\"tKunde\"> <xs:union memberTypes=\"tPerson tStudent\"></xs:union>

<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:seque开发者_Go百科nce>
        </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.


You can't use xs:union for this. You can either use xs:choice, or put the elements in a substitution group so any of them can appear in place of the element at the head of the substitution group.

0

精彩评论

暂无评论...
验证码 换一张
取 消