
XML Schemas • 177
The pattern facet allows us to deal with such requirements.
We will first see an example and then go into the syntactical details of this facet. Suppose that we want
to define a three-digit book code, to start with. The resulting scheme declaration is shown in Figure 4.41.
<xsd:simpleType name = “BookCodeType”>
<xsd:restriction base = “xsd:string”>
<xsd:minLength value = “5”/>
<xsd:maxLength value = “5”/>
<xsd:pattern value = “\p{Nd}\p{Nd}\p{Nd}”/>
</xsd:restriction>
</xsd:simpleType>
Figure 4.41 Example of a pattern facet – 1
The full schema (bookcode1.xsd) and the corresponding XML document (bookcode1.xml) are shown
in Figure ...