I've tested the pattern epxression in QuickREX for eclipse and it stated that the pattern is correct for American and Canadian Postal Code
Code:
<xsd:simpleType name="PostalFormat">
<xsd:restriction base="xsd:string">
<xsd:pattern value="(\d{5})(-\d{4})?"/>
<xsd:pattern value="([ABCEGHJKLMNPRSTVXY]\d[A-Z](( )*|-)/?\d[A-Z]\d)$"/>
</xsd:restriction>
</xsd:simpleType>
...
<xsd:element name="postal-code" type="PostalFormat"/>
However, when I use "T0J 1X0", "T0J1X0" "T0J-1X0" without the quotes in the xml document, the parser stated that the element wasn't following the pattern. When I changed the code to this instead:
Code:
<xsd:simpleType name="PostalFormat">
<xsd:restriction base="xsd:string">
<xsd:pattern value="(\d{5})(-\d{4})?|([ABCEGHJKLMNPRSTVXY]\d[A-Z]( |-)?\d[A-Z]\d)$"/>
</xsd:restriction>
</xsd:simpleType>
The input strings that I used above was accepted. Any idea why its not working for the first set of code? I know that multiple definition of patterns are accepted in xml schema