Reputation: 23
In xsd i have elements like below, where it requires city,zip to be not empty.
<addresses>
<address>
<name>abc</name>
<address>skip</Address>
....
<city/>
<zip/>
</address>
</addresses>
but in specific cases e.g. if address element content is skip, i dont want city,zip to be validated. What is the option to achieve this java or at xsd level.
Upvotes: 0
Views: 531
Reputation: 111541
You probably ought to frame your requirements not in terms of skipping validation but rather requiring occurrence or type based upon conditions. Generally "skipping validation" is handled by xs:any
, but that doesn't really appear to be what you want here.
XSD 1.0 cannot express constraints where element occurrence is dependent upon the value of other elements. You'll need XSD 1.1 for that. For an example, see Require XML element in XSD when another element has certain value?
Upvotes: 1