Can an XML Schema document specify that two items must co-occur?
For example, that there are two optional elements, and they are either both present or both absent.
a b? c d? e # giving only {ace, abcde}
# instead of all combinations: {ace, acde, abce, abcde}
<element name="root">
<complexType>
<sequence>
<element ref="a"/>
<element ref="b" minOccurs="0"/>
<element ref="c"/>
<element ref="d" minOccurs="0"/>
<element ref="e"/>
<sequence>
<complexType>
<element>
Another example: that there are two repeated elements, and that however many times the first one occurs, the second also occurs that many times:
a b^n c d^n e # where ^n is a superscript denoting number of repeats
# giving {ace, abcde, abbcdde, abbbcddde, ...}
# but no other combinations
<element name="root">
<complexType>
<sequence>
<element ref="a"/>
<element ref="b" minOccurs="0" maxOccurs="unbounded"/>
<element ref="c"/>
<element ref="d" minOccurs="0" maxOccurs="unbounded"/>
<element ref="e"/>
<sequence>
<complexType>
<element>
Maybe there's something in the identity constraints in the XML Schema spec, but that seems to be about getting exactly one instance with a certain characteristic, rather than ensuring two have the same characteristic.