[XMLSCHEMA-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

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
Interdependence between fields
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

Subscribe to the Stylus Scoop newsletter for helpful XML tips and tutorials.
Email
First Name
Last Name
Company

Download Stylus Studio 6 XML Enterprise Edition

Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2007 All Rights Reserved.