10.2. An Example of a Pattern-constrained Simple Type

Another example of a simple type is the partNumberType in Listing 10.2. The partNumberType contains a pattern that determines the valid values for a part number in a corresponding XML instance. The annotation provides an explanation of the pattern.

Listing 10.2. A Pattern-constrained Simple Type (catalog.xsd)
 <xsd:simpleType name="partNumberType" final="union" id="catalog.partNumber.sType"> <xsd:annotation> <xsd:documentation xml:lang="en"> Declaration of a part number. Each part number consists of one to three alphabetic characters followed by one to eight digits. The following part numbers, for example, are valid: J1 ABC32897 ZZ22233344 </xsd:documentation> </xsd:annotation> <xsd:restriction ...

Get XML Schema Complete Reference, The now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.