[
Lists Home |
Date Index |
Thread Index
]
> -----Original Message-----
> From: Cirip Tomas [mailto:tomas.cirip@theimo.com]
>
> Hi,
>
> does anybody have US ZIP code definition in XML Schema? Thank you
>
> Tomas
Here's one quick attempt (using regex).
Mike
=====
C:\XML\XMLSchema\Examples>cat zip.xml
<?xml version="1.0"?>
<zip>97068-9294</zip>
C:\XML\XMLSchema\Examples>cat zip.xsd
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:complexType name="ZipCode">
<xs:choice>
<xs:element name="zip" type="ZipCode5"/>
<xs:element name="zip" type="ZipCode9"/>
</xs:choice>
</xs:complexType>
<xs:simpleType name="ZipCode5">
<xs:restriction base="xs:string">
<xs:pattern value="\d{5}"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="ZipCode9">
<xs:restriction base="xs:string">
<xs:pattern value="\d{5}-\d{4}"/>
</xs:restriction>
</xs:simpleType>
</xs:schema>
C:\XML\XMLSchema\Examples>xsv zip.xml zip.xsd
<?xml version='1.0'?>
<xsv xmlns='http://www.w3.org/2000/05/xsv' docElt="{None}zip"
instanceAssessed="true" instanceErrors="0" schemaDocs="zip.xsd"
schemaErrors="0" target="file:/C:/XML/XMLSchema/Examples/zip.xml"
validation="lax" version="XSV 2.1-2 of 2002/11/25 15:00:34">
<schemaDocAttempt URI="file:/C:/XML/XMLSchema/Examples/zip.xsd"
outcome="success" source="command line"/>
</xsv>
|