Reputation: 2900
I'm trying to create a type in an XML schema to enforce an element with both:
In an XML document, the element might look like:
<Operator Permutation="true">
Equals
</Operator>
Where "Equals" would be one of the enumerations.
Is this possible? If so, how?
I've tried doing in in XMLSpy with no success. If I make a simple type, it only allows content enumeraions without attributes. If I make a complex type, it only allows attributes without content enumerations.
Edit: Thanks, David. That works perfectly, but I just added this inside the restriction so the validation ignores line breaks:
<xs:whiteSpace value="collapse"/>
Upvotes: 1
Views: 366
Reputation: 19879
How about
<xs:element name="Operator" type="MixedElement" />
<xs:complexType name="MixedElement">
<xs:simpleContent>
<xs:extension base="EnumType">
<xs:attribute name="Permutation" type="xs:boolean">
</xs:attribute>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
<xs:simpleType name="EnumType">
<xs:restriction base="xs:string">
<xs:enumeration value="Equals"/>
<xs:enumeration value="NotEquals"/>
</xs:restriction>
</xs:simpleType>
Upvotes: 2