prev table of contents next

2.2.4 Defining a String Type Restricted By Pattern

A string type may also be restricted by a pattern facet. The example below defines a type for strings of arbitrary length consisting of 'L' and 'R' only. Once more, no Java class is required for DirType.

<xsd:simpleType name="DirType">
  <xsd:restriction base="xsd:string">
    <xsd:pattern value="[LR]*"/>
  </xsd:restriction>
</xsd:simpleType>
The syntax for regular expressions in pattern facets provides the basics for repetition, alternatives and grouping. It should be noted that a regular expression is always matched against the entire string value.


prev table of contents next