I'm using Eclipse IDE to build an XML Schema for processing by JAXB, but I'm getting a validation error on the following:
<xsd:element name="testEl">
<xsd:complexType>
<xsd:choice>
<xsd:sequence>
<xsd:element name="testElChild">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="tec1"/>
<xsd:element name="tec2"/>
</xsd:sequence>
<xsd:attribute name="type" use="required" fixed="yes"/>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
<xsd:sequence>
<xsd:element name="testElChild">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="tec3"/>
<xsd:element name="tec4"/>
</xsd:sequence>
<xsd:attribute name="type" use="required" fixed="no"/>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:choice>
</xsd:complexType>
</xsd:element>
Basically, I'm trying to specify that if the type attribute of element testElChild
has a value of "yes" then it should contain child elements tec1
and tec2
, but if the type attribute has a value of "no" then it should contain child elements tec3
and tec4
.
What is wrong with the above schema and/or how do I go about accomplishing the intention with valid XML schema?