xs:pattern

Purpose This element is a restriction facet for pattern matching, i.e. for constraining the value space in such a way that only literals matching the specified pattern (regular expression) are allowed for the lexical space.
Parent element xs:restriction
Child elements None
Attributes value
Restrictions

The following restriction applies for the xs:pattern element:

  • Multiple xs:pattern Elements
    Multiple xs:pattern elements are permitted under one xs:restriction element. However, specifying two xs:pattern elements within the scope of one xs:restriction element is not the same as specifying two xs:pattern elements within separate xs:restriction elements; a logical "OR" operation is performed with xs:pattern elements belonging to the same xs:restriction element.

Attributes
Name Type Description
value xs:string The value attribute allows you to specify a regular expression as defined in http://www.w3.org/TR/xmlschema-2/#dt-regex as a pattern that all members of the value space must match.

Example

This simple example shows the application of the xs:pattern element for the definition of a German zip code, which consists of five decimal digits:

<xs:simpleType name="german-zipcode">
  <xs:restriction base='string'>
    <xs:pattern value='[0-9]{5}'/>
  </xs:restriction>
</xs:simpleType>