Reputation: 410
I want to be able to change the expected child elements of a parent element when the parent element has a particular attribute value set.
So the following would validate:
<Parent childConfig="A">
<Child validForConfigA="ABC"/>
</Parent>
or:
<Parent childConfig="B">
<Child validForConfigB="XYZ"/>
</Parent>
But this snippet would not validate (because the attribute "validForConfigB" is not valid when the parent's childConfig="A"):
<Parent childConfig="A">
<Child validForConfigB="ABC"/>
</Parent>
Can this kind of logic work in DTD or XSD?
Upvotes: 0
Views: 59
Reputation: 12817
Not with a DTD, but with an XML Schema 1.1 validator you should be able to use type alternatives.
Upvotes: 1