Is it possible to use xs: union for complexTypes?

<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> 

Here's how it should look. The task is to remove the student from the Person, and then give the opportunity to use one of two types for the Kunde element.

This seems unacceptable.

+8
xml union xsd
source share
1 answer

You cannot use xs: union for this. You can either use xs: choice or place items in a substitution group so that any of them can appear instead of the element at the head of the substitution group.

+2
source share

All Articles