I have a schema like below, the color elements of default and instance have identical restriction (red/green/blue). I want to move the restriction to higher level and set all color element with it (Like declare a type or enum in Java/C#)
How can I do for that?
<xs:element name="something">
<xs:complexType>
<xs:sequence>
<xs:element name="instance" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="name" type="xs:string" use="required"/>
<xs:attribute name="color" use="required">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="red"/>
<xs:enumeration value="green"/>
<xs:enumeration value="blue"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:complexType>
</xs:element>
<xs:element name="default">
<xs:complexType>
<xs:attribute name="color" use="required">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="red"/>
<xs:enumeration value="green"/>
<xs:enumeration value="blue"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
Define the type:
And reference it: