Given XSD:
<xs:element name="color">
<xs:complexType>
<xs:attribute name="type">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="white"/>
<xs:enumeration value="black"/>
<xs:enumeration value="red"/>
<xs:enumeration value="green"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="number" use="optional/>
</xs:complexType>
</xs:element>
How would I write an assertion so that
- if
<color>
has@type
white or black, it cannot also have the@number
attribute, and - if
<color>
has@type
red or green, it must also have the@number
attribute.
XSD 1.1