Given the following xml structure:
<root>
<definitions>
<definition key="def1" group="group1" isExclusiveInGroup="true" />
<definition key="def2" group="group1" isExclusiveInGroup="false" />
<definition key="def3" group="group1" isExclusiveInGroup="false" />
<definition key="def4" group="group2" isExclusiveInGroup="true" />
</definitions>
<items>
<item key="item1" definitionKey="def1" />
<item key="item2" definitionKey="def4" />
</items>
</root>
What I want to validate, in english:
It is acceptable for the items element to contain an item element referencing def2 and another item element referencing def3. They are not exclusive within group1.
It is acceptable for the items element to contain an item element referencing def1 and another item element referencing def4. They are part of different groups, thus their exclusivity does not conflict.
It is not acceptable for the items element to contain an item element referencing def1 and another item element referencing any other definition that has a group attribute equal to group1. Def1 is exclusive to it's group so there can not be any other items referencing a definition within the same group
What xsd structures/elements would I use to enforce such a specification?