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

Re: Help with choice model group!

From: Bob Schloss <rschloss@us.ibm.com>
Date: Tue, 15 Jun 2004 10:02:49 -0400
To: Alexander Sherwood <asherwood@phs-net.com>
Cc: xmlschema-dev@w3.org
Message-ID: <OF85A82F2F.F7DEC220-ON85256EB4.004BE9A5-85256EB4.004D29B9@us.ibm.com>

Hi Alexander,

      I'm not sure that the choice model group is the best construct for
what you want to do.  I think there are 2 other approaches.

      If you had
  <paymentAddress street=".." city=".." zip=".."/> !-- 0 or 1 --!
  <mailingAddress street=".." city=".."  zip=".."/>   !-- 0 or 1 --!

      Then you could write
 <xs:element name="paymentAddress" type="AddressType" minOccurs="0"
 <xs:element name="mailingAddress" type="AddressType" minOccurs="0"

and you'd define AddressType as type that has attributes street, city and
zip and no element content.

      Warning: This would still validate cases where <addresses> was an
empty element.  It would also require stylesheets (or other programs that
handle your XML documents) to handle 2 element names, rather than the one
element name you originally specified.

      An alternative approach would be to use your original element names,
<xs:element name="addresses">
 <xs:element name="address" minOccurs="1" maxOccurs="2">
 !-- specify a UNIQUE identify-definition-constraint specification using
field xpath="address/@type" --!

      which would make it so that you could not have 2 type="payment" or 2
type="mailing" address elements within a single addresses element
information item.


Scalable XML Infrastructure
IBM Thomas J. Watson Research Center
Yorktown Heights, New York, USA

             <asherwood@phs-ne                                          To 
             t.com>                    xmlschema-dev@w3.org                
             Sent by:                                                   cc 
             uest@w3.org                                           Subject 
                                       Help with choice model group!       
             06/15/2004 09:26                                              

Greetings all,

Given the following snippet:

             <address street="" city="" state="" zip="" type="payment |

I'd like to require at least one _address_ element with a type attribute
equal to "mailing", and _one_ optional address element with a type
attribute equal to "payment", for a total maxOccurs of 2.

Any ideas? Thanks!

Alex Sherwood
PHS Collection Agency
P:   813-283-4579
F:   301.664.6834
W: www.phs-net.com
Received on Tuesday, 15 June 2004 10:15:49 UTC

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