Reputation: 3450
Is there any way to restrict the use of an XML element's sub elements, depending on the attribute value of the parent element in XML Schema? How does the schema have to look like?
<option name="mike" value="excset">
<excludingsets>
<excludingset>
<option name="hd"/>
</excludingset>
</excludingsets>
</option>
<option name="mike" value="args">
<arguments>
<argument name="kjk" validatortype="regex">
<regex value="dkas"/>
</argument>
</arguments>
</option>
As you can see in this example, the element <excludingset>
should only be valid if the attribute value of <option>
is value="excset"
, and the element <arguments>
if it has value="args"
.
Thanks in advance.
Upvotes: 3
Views: 3285
Reputation: 49311
Not in W3C XML Schema 1.0. You can in ISO RelaxNG and, I believe, in W3C XML Schema 1.1.
Upvotes: 2