The easiest way to have two different types for Person elements is to use local Person declarations in two different contexts that you mean. For example, you can say:
<xs:element name="Add"> <xs:complexType> <xs:sequence> <xs:element name="Person" type="AddPerson"/> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="Update"> <xs:complexType> <xs:sequence> <xs:element name="Person" type="ChangePerson"/> </xs:sequence> </xs:complexType> </xs:element>
This example assumes that you have redefined two of your complex types: AddPerson and ChangePerson.
If you also want the two complex types to be explicitly connected, you can get them as a restriction on the generic Person type.
<xs:complexType name="Person"> <xs:annotation> <xs:documentation>This is the generic definition for persons</xs:documentation> </xs:annotation> <xs:sequence> <xs:element name="PartyName" type="xs:string" minOccurs="0" maxOccurs="1"/> <xs:element name="GenderCode" type="GenderCode_Type" minOccurs="0" maxOccurs="1"/> <xs:element name="BirthDate" type="xs:date" minOccurs="0" maxOccurs="1"/> </xs:sequence> </xs:complexType> <xs:complexType name="ChangePerson"> <xs:annotation> <xs:documentation>This is the definition when changing a person</xs:documentation> </xs:annotation> <xs:complexContent> <xs:restriction base="Person"> <xs:sequence> <xs:element name="PartyName" type="xs:string" minOccurs="0" maxOccurs="1"/> <xs:element name="GenderCode" type="GenderCode_Type" minOccurs="0" maxOccurs="1"/> <xs:element name="BirthDate" type="xs:date" minOccurs="0" maxOccurs="1"/> </xs:sequence> </xs:restriction> </xs:complexContent> </xs:complexType> <xs:complexType name="AddPerson"> <xs:annotation> <xs:documentation>This is the definition when adding a person</xs:documentation> </xs:annotation> <xs:complexContent> <xs:restriction base="Person"> <xs:sequence> <xs:element name="PartyName" type="xs:string" minOccurs="1" maxOccurs="1"/> <xs:element name="GenderCode" type="GenderCode_Type" minOccurs="1" maxOccurs="1"/> <xs:element name="BirthDate" type="xs:date" minOccurs="0" maxOccurs="1"/> </xs:sequence> </xs:restriction> </xs:complexContent> </xs:complexType>
Here, the generic Person type is identical to AddPerson; I defined AddPerson using an empty constraint only to symmetry the inference of both types related to the operation from the generic type.
Whether such an explicit relationship between your types is really useful for achieving your goals will depend, of course, in part on what your system uses to determine the types of circuitry.
source share