Saturday, 10 January 2015

Presence of elements based on attribute in XSD



I have 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 a XSD, so that if 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?


No comments:

Post a Comment