Facets: pattern

The pattern facet can be used to constraint an element to contain only a series of characters. A commonly used pattern value is a regular expression. For example, in the code snippet on the right, the EmpInitials element can contain only two uppercase letters between A and Z.

Similarly, if the pattern value is as follows, [Abc] indicates that the element can contain only three permissible values: A, b, or c.

    <xs:pattern value="[Abc]"/>

If pattern value="[a-zA-Z][[a-zA-Z]", the element can contain only two lowercase or uppercase characters between the letters A and Z.

In addition, if pattern value="[0-9][[0-9]", the element can contain only two numeric digits between 0 and 9.
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:element name="EmpInitials">
    <xs:simpleType>

      <xs:restriction base="xs:string">
        <xs:pattern value="[A-Z][A-Z]"/>
      </xs:restriction>

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


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