I am trying to create an XSD schema for the following XML:
<root>
<!-- The actual file must contain one of the following constraints -->
<constraint type="interval">
<min>100</min>
<max>200</max>
</constraint>
<constraint type="equals">
<value>EOF</value>
</constraint>
</root>
The child elements of the constraint element depends on the value of the type attribute.
I have successfully validated the XML using an abstract type defining the type attribute, and two extending types defining the child elements. This would require me to decorate the XML with an xsi:type attribute, naming the actual extending type:
<constraint type="interval" xsi:type="intervalConstraintType">
<min>100</min>
<max>200</max>
</constraint>
Sadly, I'm not in control of the XML-structure and new attributes will be hard to introduce.
Is this doable with XSD? Are there alternatives that are more suitable?