I have two request types which internally use the same compleType element. The distinguishing factor between the two requests is an element attribute value (apart from the request wrapper). Need to add this condition in XSD to use it as part of schema validation.
Here is the sample elements declaration
<xsd:element name="searchRequest" type="searchRequest_Type"/>
<xsd:complexType name="searchRequest_Type">
<xsd:sequence>
<xsd:element ref="bip:BIPOrder" minOccurs="1">
</xsd:element>
</xsd:sequence>
</xsd:complexType>
<xsd:element name="advanceSearchRequest" type="advanceSearchRequest_Type"/>
<xsd:complexType name="advanceSearchRequest_Type">
<xsd:sequence>
<xsd:element ref="bip:BIPOrder" minOccurs="1">
</xsd:element>
</xsd:sequence>
</xsd:complexType>
BIPOrder is a complexType with many other nested ComplexType elements inside it. One of the Element attribute value in one of the complexType is the distinguishing factor between the above two requests.
Like
<myap:searchRequest>
<bip:BIPOrder>
<....>
<....>
<BIPSearchType id="459">Normal Search</BIPSearchType>
<....>
</bip:BIPOrder>
</myap:searchRequest>
<myap:advanceSearchRequest>
<bip:BIPOrder>
<....>
<....>
<BIPSearchType id="479">Advanced Search</BIPSearchType>
<...>
</bip:BIPOrder>
</myap:advanceSearchRequest>
I am looking to add the restriction on BIPSearchType "id" attribute value in my XSD so that when the request XML is validated it should satisfy this condition also.
Currently I am able to validate the whole request via XSD except this condition. I am explicitly validating this condition after the schema validation to check correct "BIPSearchType" "id" is sent along with the request.
Please advise on how I can acheive this in my XSD.
Thanks in advance for your kind help.
idattribute, but your description says otherwise: they are also distinguished by the element names of the parent elements of bip:BIPOrder. (Short version: you have violated the principle of DRY; the universe will punish you.) - C. M. Sperberg-McQueen