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

Re: Help with choice model group!

From: Henry S. Thompson <ht@inf.ed.ac.uk>
Date: Tue, 15 Jun 2004 15:14:53 +0100
To: Alexander Sherwood <asherwood@phs-net.com>
Cc: xmlschema-dev@w3.org
Message-ID: <f5b7ju8di1u.fsf@erasmus.inf.ed.ac.uk>

This is a pretty extreme hack, but I needed a break from something
else -- it's an object lesson in abusing identity constraints.  If
I've understood you correctly, it does what you want -- one or two
address elements, type='mailing' must be present, type='payment' is
also OK, either order if both present.

<xs:element name="addresses">
    <xs:element ref="address"/>
    <xs:element ref="address" minOccurs="0"/>
   <xs:attribute fixed="mailing" type="xs:token" name="mailing"/>
  <xs:keyref name="reqMailing" refer="keys">
   <xs:selector xpath="."/>
   <xs:field xpath="@mailing"/>
  <xs:key name="keys">
   <xs:selector xpath="address"/>
   <xs:field xpath="@type"/>
 <xs:element name="address">
   <xs:attribute name="street"/>
   <xs:attribute name="city"/>   
   <xs:attribute name="state"/>
   <xs:attribute name="zip"/>
   <xs:attribute name="type">
     <xs:restriction base="xs:token">
      <xs:enumeration value="payment"/>      
      <xs:enumeration value="mailing"/>

Protective clothing should be warn when working with this schema :-)

 Henry S. Thompson, HCRC Language Technology Group, University of Edinburgh
                     Half-time member of W3C Team
    2 Buccleuch Place, Edinburgh EH8 9LW, SCOTLAND -- (44) 131 650-4440
            Fax: (44) 131 650-4587, e-mail: ht@inf.ed.ac.uk
                   URL: http://www.ltg.ed.ac.uk/~ht/
[mail really from me _always_ has this .sig -- mail without it is forged spam]
Received on Tuesday, 15 June 2004 10:15:27 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 23:15:22 UTC