XSD Definition for Enumerated Value

This solution worked for me:

<xs:element name="color">
   <xs:simpleType>
      <xs:restriction base="xs:string">
          <xs:enumeration value="green"/>
          <xs:enumeration value="red"/>
          <xs:enumeration value="blue"/>
      </xs:restriction>
   </xs:simpleType>
</xs:element>

You can define an enumeration within the context of a simpleType.

 <xs:simpleType name="color" final="restriction" >
    <xs:restriction base="xs:string">
        <xs:enumeration value="green" />
        <xs:enumeration value="red" />
        <xs:enumeration value="blue" />
    </xs:restriction>
</xs:simpleType>
<xs:element name="SomeElement">
    <xs:complexType>
        <xs:sequence>
            <xs:element name="Color" type="color" />
        </xs:sequence>
    </xs:complexType>
</xs:element>

Tags:

Xsd