Restrictions on a Set of Values
To limit the content of an XML element to a set of acceptable values, we would use the enumeration constraint.
The example below defines an element called "Color" with a restriction. The only acceptable values are: green, red, blue:
<?xml version="1.0" encoding="windows-1252" ?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.example.org"
targetNamespace="http://www.example.org" elementFormDefault="qualified">
<xsd:element name="SomeElement">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="Color" type="xsd:colorT"/>
<xsd:element name="code" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:simpleType name="colorT">
<xsd:restriction base="xsd:string">
<xsd:enumeration value="green"/>
<xsd:enumeration value="red"/>
<xsd:enumeration value="blue"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:schema>