OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.


Help: OASIS Mailing Lists Help | MarkMail Help



   RE: [xml-dev] XML Schema and ZIP code

[ 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).


C:\XML\XMLSchema\Examples>cat zip.xml
<?xml version="1.0"?>


C:\XML\XMLSchema\Examples>cat zip.xsd
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema";>

<xs:complexType name="ZipCode">
  <xs:element name="zip" type="ZipCode5"/>
  <xs:element name="zip" type="ZipCode9"/>

<xs:simpleType name="ZipCode5">
 <xs:restriction base="xs:string">
  <xs:pattern value="\d{5}"/>

<xs:simpleType name="ZipCode9">
 <xs:restriction base="xs:string">
  <xs:pattern value="\d{5}-\d{4}"/>


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"/>


News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS