I have an XML file like this
<listOfA>
<a type="1">
<name></name>
<surname></surname>
</a>
<a type="2">
<name></name>
<id></id>
</a>
</listOfA>
I'd like to make an XSD, so that if the value of the attribute "type" is 1, the name and surname elements must be present, and when it's 2, name and id must be there. I tried to generate the XSD in XSD schema generator, but it made the surname and id element minOccurs=0. How could I make it work?
You can do this using XSD 1.1's Conditional Type Assignment: