W3C home > Mailing lists > Public > xmlschema-dev@w3.org > June 2002

union(?) question

From: Doug <ummmmm22@yahoo.com>
Date: Tue, 4 Jun 2002 18:20:16 -0700 (PDT)
Message-ID: <20020605012016.98096.qmail@web10907.mail.yahoo.com>
To: xmlschema-dev@w3.org

first of all, forgive me if this shows up twice.  i
tried to send it once (from a different email address)
hours ago, but i haven't seen it appear yet.  so...

--------------------------------------------------------
i'm trying to define 4 custom, "named" simpleTypes,
each a restriction of xsd:string, then combine them
into a "named" type that allows any one of those
simpleType formats.

initial simpleTypes:

      <xsd:simpleType name="VisaNumber">
         <xsd:restriction base="xsd:string">
            <xsd:pattern value="4\d{15}"/>
            <xsd:pattern value="4\d{12}"/>
         </xsd:restriction>
      </xsd:simpleType>

      <xsd:simpleType name="MasterCardNumber">
         <xsd:restriction base="xsd:string">
            <xsd:pattern value="51\d{14}"/>
            <xsd:pattern value="52\d{14}"/>
            <xsd:pattern value="53\d{14}"/>
            <xsd:pattern value="54\d{14}"/>
            <xsd:pattern value="55\d{14}"/>
         </xsd:restriction>
      </xsd:simpleType>

      <xsd:simpleType name="AMEXNumber">
         <xsd:restriction base="xsd:string">
            <xsd:pattern value="34\d{13}"/>
            <xsd:pattern value="37\d{13}"/>
         </xsd:restriction>
      </xsd:simpleType>

      <xsd:simpleType name="DiscoverNumber">
         <xsd:restriction base="xsd:string">
            <xsd:pattern value="6011\d{12}"/>
         </xsd:restriction>
      </xsd:simpleType>

i'm very new to XML Schema, and the only thing i could
come up with that seems promising is "union".  so...
would this syntax do the trick?  is there a better
way?

      <xsd:simpleType name="AcceptedCreditCards">
         <xsd:union memberTypes="VisaNumber
MasterCardNumber AMEXNumber DiscoverNumber"/>
      </xsd:simpleType>

thanks. 

__________________________________________________
Do You Yahoo!?
Yahoo! - Official partner of 2002 FIFA World Cup
http://fifaworldcup.yahoo.com
Received on Tuesday, 4 June 2002 21:20:18 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 11 January 2011 00:14:31 GMT