constrain one out of two elements or both(but not zero)
Posted: Tue Jul 18, 2006 1:53 pm
Hi, all
I need schema to forse one of elements to have exactly one out of two provided elements or both of them (in any order), but not zero.
I tried:
<xsd:element name="parent">
<xs:complexType>
<xs:sequence>
<xs:element name="foo" type="fooT" minOccurs="0"/>
<xs:element name="bar" type="barT" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
</xsd:element>
But, this allows also zero elements.
Also tried:
<xsd:element name="parent">
<xs:complexType>
<xs:choice>
<xs:element name="foo" type="fooT"/>
<xs:element name="bar" type="barT"/>
<xs:group ref="foo_and_bar"/>
</xs:choice>
</xs:complexType>
</xsd:element>
<xs:group name="foo_and_bar">
<xs:sequence>
<xs:element name="foo" type="fooT"/>
<xs:element name="bar" type="barT"/>
</xs:sequence>
</xs:group>
But this gives me error: "content model non-deterministic (possible causes: name equality, overlapping occurance or substitution groups)".
I need schema to forse one of elements to have exactly one out of two provided elements or both of them (in any order), but not zero.
I tried:
<xsd:element name="parent">
<xs:complexType>
<xs:sequence>
<xs:element name="foo" type="fooT" minOccurs="0"/>
<xs:element name="bar" type="barT" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
</xsd:element>
But, this allows also zero elements.
Also tried:
<xsd:element name="parent">
<xs:complexType>
<xs:choice>
<xs:element name="foo" type="fooT"/>
<xs:element name="bar" type="barT"/>
<xs:group ref="foo_and_bar"/>
</xs:choice>
</xs:complexType>
</xsd:element>
<xs:group name="foo_and_bar">
<xs:sequence>
<xs:element name="foo" type="fooT"/>
<xs:element name="bar" type="barT"/>
</xs:sequence>
</xs:group>
But this gives me error: "content model non-deterministic (possible causes: name equality, overlapping occurance or substitution groups)".