I have schema where I want either of element is mandatory and they should not repeat.
EDITED -- Here valid request can contain both query and id in request or with only query or id element is also valid. e.g:
<soapenv:Body>
<ws:SomeOperation>
<SoapOperation>
<query>test</query>
<id>1</id>
</SoapOperation>
</ws:SomeOperation>
</soapenv:Body>
Valid Requests:
- with query and id element.
- with only query element.
- with only id element.
Invalid Requests:
- without query and id element.
- with multiple query element.
- with multiple id element.
I want query or id must be present. One of them is mandatory. I tried below things:
<xs:sequence>
<xs:element minOccurs="0" name="id">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:minLength value="1" />
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element minOccurs="0" name="query">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:minLength value="1" />
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:sequence>
Here the problem is none of them is mandatory and making any one as minoccurs=1 will make that field mandatory ( e.g. if i mark id as minoccurs=1 then id field is mandatory but my valid request can have only query and not id) and there can be possibility of both tags to be present as well.
Also I tried choice tag.
Using simple choice with will make these tags repeat which also i do not want. The tag should not repeat.