Not with a DTD, but with an XML Schema 1.1 validator you should be able to use type alternatives.
Schema that changes based on attribute values
Pregunta
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?
Solución
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow