My requirement is to validate an xml with two different validation strategies. In strategy 1, the xml is required to have instances of an element with certain required attributes. In strategy 2, the xml is required to have instances of the same element with different required attributes. So, the idea is that there are two different sets of the same element with different set of required attributes for each set. Is there a way to validate this with using only one xsd. My only solution so far is to use two different xsd files to validate.
Example 1:
<?xml version="1.0" encoding="UTF-8"?>
<root>
<element firstName="something"/> <!--required -->
<element lastName="something"/> <!-- required -->
<element phoneNumber="something"/> <!-- not required -->
<root>
Example 2:
<?xml version="1.0" encoding="UTF-8"?>
<root>
<element firstName="something"/> <!-- not required -->
<element lastName="something"/> <!-- required -->
<element phoneNumber="something"/> <!-- required -->
<root>
Can the validation by xsd be achieved?