Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

"if statement" in Xml Schema

Status
Not open for further replies.

mystiqu

Programmer
Jul 20, 2006
1
SE
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>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top