I am trying to create an XSD schema for the following XML:
<root>
<constraint type="interval">
<min>100</min>
<max>200</max>
</constraint>
<constraint type="equals">
<value>EOF</value>
</constraint>
</root>
child elements of a constraint element depend on the value of the type attribute.
I successfully validated XML using an abstract type defining a type attribute and two extending types defining child elements. This would require me to decorate the XML with the xsi: type attribute, naming the actual extensible type:
<constraint type="interval" xsi:type="intervalConstraintType">
<min>100</min>
<max>200</max>
</constraint>
Unfortunately, I do not control the XML structure, and the new attributes will be hard to imagine.
Can this be done with XSD? Are there alternatives that are more suitable?
user54639
source
share