How to set enumeration restrictions for a complex type restriction??
i-e I want to define an element in the XSD such that it can have attributes and has restrictions.
How to set enumeration restrictions for a complex type restriction??
i-e I want to define an element in the XSD such that it can have attributes and has restrictions.
You can define a complex type with simple content that can extend a simple type with the enumeration restrictions that you want adding additional attributes. See a working example below:
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:simpleType name="restrictedType">
<xs:restriction base="xs:string">
<xs:enumeration value="v1"/>
<xs:enumeration value="v2"/>
</xs:restriction>
</xs:simpleType>
<xs:complexType name="testType">
<xs:simpleContent>
<xs:extension base="restrictedType">
<xs:attribute name="att"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
<xs:element name="test" type="testType"/>
</xs:schema>
a valid instance will be
<test att="x">v1</test>
Best Regards, George