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:complexType>
   <xs:sequence>
    <xs:element ref="address"/>
    <xs:element ref="address" minOccurs="0"/>
   </xs:sequence>
   <xs:attribute fixed="mailing" type="xs:token" name="mailing"/>
  </xs:complexType>
  <xs:keyref name="reqMailing" refer="keys">
   <xs:selector xpath="."/>
   <xs:field xpath="@mailing"/>
  </xs:keyref>
  <xs:key name="keys">
   <xs:selector xpath="address"/>
   <xs:field xpath="@type"/>
  </xs:key>
 </xs:element>
 
 <xs:element name="address">
  <xs:complexType>
   <xs:attribute name="street"/>
   <xs:attribute name="city"/>   
   <xs:attribute name="state"/>
   <xs:attribute name="zip"/>
   <xs:attribute name="type">
    <xs:simpleType>
     <xs:restriction base="xs:token">
      <xs:enumeration value="payment"/>      
      <xs:enumeration value="mailing"/>
     </xs:restriction>
    </xs:simpleType>
   </xs:attribute>
  </xs:complexType>
 </xs:element>

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

ht
-- 
 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 GMT

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