I have an XML snippet like below:
<Type>
<name>content1</name>
<priority></priority>
<schedule>30 0/1 * * * ?</schedule>
<length>2</length>
<patterns>
<pattern>[^\s]*\.DOC</pattern>
</patterns>
</Type>
Some ‘type’ tags will not contain the
<priority></priority>
<schedule>30 0/1 * * * ?</schedule>
elements. But when I validate it against the given ‘XSD’ file it will throw an error. How can I ignore or check if the tags are available validate it condition on the XSD file? Is it possible?
I am using Java Validator to validate this.
Thanks in advance.
In your XSD file, make the <priority> & <schedule> optional. Setting the minOccurs to 0 make the element optional. If the elements exists in the xml the xsd will validate it, if not, the xsd won’t validate it.