Hi
I wonder if anyone know how I can accomplish something similar to an "if statement" in an xml schema.
I would like to allow certain data to be specified dependant on which data I have supplied earlier in my xml document.
Take a look at the xml schema below:
If I use "Normal" as the CallType, I would like to only allow the SubType to be "ServiceType", but if I use "Transaction" as the CallType, I would like to be able to use "Begin", "Prepare", "Commit" or "Rollback" as the ServiceType.
How can I accomplish that?
Regards
Mikael
<xs:element name="Services">
<xs:complexType>
<xs:sequence>
<xs:element ref="CallType"/>
<xs:element ref="SubType"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="CallType">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="Normal"/>
<xs:enumeration value="Transaction"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="SubTypeTransaction">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="ServiceType"/
<xs:enumeration value="Begin"/>
<xs:enumeration value="Prepare"/>
<xs:enumeration value="Commit"/>
<xs:enumeration value="Rollback"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
I wonder if anyone know how I can accomplish something similar to an "if statement" in an xml schema.
I would like to allow certain data to be specified dependant on which data I have supplied earlier in my xml document.
Take a look at the xml schema below:
If I use "Normal" as the CallType, I would like to only allow the SubType to be "ServiceType", but if I use "Transaction" as the CallType, I would like to be able to use "Begin", "Prepare", "Commit" or "Rollback" as the ServiceType.
How can I accomplish that?
Regards
Mikael
<xs:element name="Services">
<xs:complexType>
<xs:sequence>
<xs:element ref="CallType"/>
<xs:element ref="SubType"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="CallType">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="Normal"/>
<xs:enumeration value="Transaction"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="SubTypeTransaction">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="ServiceType"/
<xs:enumeration value="Begin"/>
<xs:enumeration value="Prepare"/>
<xs:enumeration value="Commit"/>
<xs:enumeration value="Rollback"/>
</xs:restriction>
</xs:simpleType>
</xs:element>