Consider the following:
<xs:complexType name="A">
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:group ref="subAGroup"/>
<xs:group ref="xGroup"/>
</xs:choice>
</xs:complexType>
<xs:complexType name="B">
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:group ref="subBGroup"/>
<xs:group ref="xGroup"/>
</xs:choice>
</xs:complexType>
What I want to happen is if one of the elements in the xGroup is a child, grandchild, etc. of A then its children must be part of the subAGroup or xGroup. If B is its ancestor then its children must be in the subBGroup or xGroup.