W3C home > Mailing lists > Public > xmlschema-dev@w3.org > November 2007

Interdependence between fields

From: Adrian Iacob <adrian.iacob@gmail.com>
Date: Fri, 16 Nov 2007 08:36:10 +0200
Message-ID: <cd5669280711152236w56752927h73a18ba3deb64672@mail.gmail.com>
To: xmlschema-dev@w3.org
I have an interdependence between 2 fields value like this: One field is
country and the second is town. First field can have USA, Canada, Mexic. The
second can have for example Montreal, Toronto, New York, Washington, Boston,
Veracruz.

xml ok:
<myxml>
  <country>Canada</country>
  <town>Montreal</town>
</myxml>

<myxml>
  <country>USA</country>
  <town>Washington</town>
</myxml>

xml *not ok

*<myxml>
  <country>USA</country>
  <town>Veracruz</town>
</myxml>

<myxml>
  <country>Canada</country>
  <town>New York</town>
</myxml>

I could restrict that the country has only contries and town has only towns
like this:

<xs:element name="country" >
  <xs:simpleType>
    <xs:restriction base="xs:string">
      <xs:enumeration value="Canada"/>
      <xs:enumeration value="USA"/>
      <xs:enumeration value="Mexic"/>
    </xs:restriction>
  </xs:simpleType>
</xs:element>

Montreal, Toronto, New York, Washington, Boston, Veracruz.
 <xs:element name="town" >
  <xs:simpleType>
    <xs:restriction base="xs:string">
      <xs:enumeration value="Montreal"/>
      <xs:enumeration value="Toronto"/>
      <xs:enumeration value="New York"/>
      <xs:enumeration value="Washington"/>
      <xs:enumeration value="Boston"/>
      <xs:enumeration value="Veracruz"/>
    </xs:restriction>
  </xs:simpleType>
</xs:element>

*My question:
*How can I restrict that Canada is allowed with Montreal and Toronto, USA is
with New York, Washington or Boston and Mexic is allowed only with Veracruz.



Please Help.
Thanks Adrian
Received on Friday, 16 November 2007 14:47:52 GMT

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