Facets: enumeration

The enumeration facet can be used to define a constraint for an element to contain only specified values. These values depend upon the data types mentioned in the restriction element. For example, in the code snippet on the right, the enumeration facet indicates that the EmpID element can take only three string values: ABC, LMN, and XYZ.

Similarly, in the following code snippet, the enumeration facet indicates that the priority element can take only three numeric values: 1, 2, and 3.

    <xs:element name="priority">
      <xs:simpleType>
       <xs:restriction base="xs:integer">
        <xs:enumeration value="1"/>
        <xs:enumeration value="2"/>
        <xs:enumeration value="3"/>

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:element name="DeptID">
    <xs:simpleType>

      <xs:restriction base="xs:string">
        <xs:enumeration value="ABC"/>
        <xs:enumeration value="LMN"/>
        <xs:enumeration value="XYZ"/>
      </xs:restriction>

    </xs:simpleType>
  </xs:element>

// Additional declarations...
Click the Next button to continue.