Java Reference
In-Depth Information
<xsd:simpleType name="SSN">
<xsd:restriction base="xsd:string">
<xsd:pattern value="\d{3}(-)?\d{2}(-)?\d{4}" />
<xsd:minLength value="9" />
<xsd:maxLength value="11" />
</xsd:restriction>
</xsd:simpleType>
Note that this is a very simple and straightforward representation, but it is not perfect. It is a
rule that none of the three fields in a Social Security number is allowed to be all zeros, and
this regex does not account for that.
Canadian postal code
Canadian postal codes contain six characters of alternating letters and numbers. The first three
identify the Forward Sortation Area and the second three identify the Local Delivery Unit.
The following are valid example codes: M1A 1A1, H9Z 9Z9.
<xs:element name="caPostalCode">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:pattern value="[ABCDEGHJKLMNPRSTVXY]\d[A-Z] \d[A-Z]\d" />
<xs:minLength value="7" />
<xs:maxLength value="7" />
</xs:restriction>
</xs:simpleType>
</xs:element>
Canadian provinces
There are 14 Canadian provinces. Like the U.S. states, they use two-character abbreviations:
<xsd:simpleType name="CAProvince">
<xsd:restriction base="xsd:string">
<xsd:length value="2" />
<xsd:enumeration value="AB" />
<xsd:enumeration value="BC" />
<xsd:enumeration value="MB" />
<xsd:enumeration value="NB" />
<xsd:enumeration value="NL" />
<xsd:enumeration value="NS" />
<xsd:enumeration value="NT" />
<xsd:enumeration value="NU" />
<xsd:enumeration value="ON" />
<xsd:enumeration value="PE" />
<xsd:enumeration value="QC" />
<xsd:enumeration value="SK" />
Search WWH ::




Custom Search