XSD: required nested tags if optional parent exists



I have tags which are optional in my XML, if the optional tag is present I then need the child tags of that element to be required, how can I achieve this using XSD (or another solution if this is not possible in XSD)?


An example part of my XML:



<xs:element name="deviceLocation" minOccurs="0" maxOccurs="unbounded" nillable="true">
<xs:complexType>
<xs:sequence>
<xs:element type="xs:string" name="xPos"/>
<xs:element type="xs:string" name="yPos"/>
<xs:element type="xs:string" name="zPos"/>
</xs:sequence>
</xs:complexType>
</xs:element>


As you can see the deviceLocation tag is optional - if this tags exists I then want the child tags xPos, yPos and zPos to be required.


No comments:

Post a Comment