Reputation: 5679
There is a xml structure as follows
Is it possible in XSD to block "dataRef" element referencing it's parent "data/dataRef" attribute value (basically a child can't match parents value constraint). Is it possible to make two way relationships mandatory as seen in the "order/item" of "AAAA" which has a reference to "AEAR" "data" element but that element does not have a "AAAA" data item referencing "data" "AAAA"
<data dataRef="AAAA">
<order>
<!-- this should not be allowed to reference its own parent element -->
<item>
<dataRef>AAAA</dataRef>
</item>
<item>
<dataRef>BASA</dataRef>
</item>
<item>
<dataRef>AEAR</dataRef>
</item>
</order>
</data>
<data dataRef="AEAR">
<order>
<!-- since this is referenced from data/@dataRef="AAAA" there should be an element pointing back to "dataRef" "AAAA" as it is a two way relationship -->
<item>
<dataRef>BASA</dataRef>
</item>
</order>
</data>
Upvotes: 0
Views: 97
Reputation: 163587
As is so often the answer when people want to express complex constraints in XSD, the answer is that you can do it in XSD 1.1 with assertions, but not in XSD 1.0.
Upvotes: 1