- 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
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 <addresses> <paymentAddress street=".." city=".." zip=".."/> !-- 0 or 1 --! <mailingAddress street=".." city=".." zip=".."/> !-- 0 or 1 --! </addresses> Then you could write <xs:sequence> <xs:element name="paymentAddress" type="AddressType" minOccurs="0" maxOccurs="1"/> <xs:element name="mailingAddress" type="AddressType" minOccurs="0" maxOccurs="1'/> </xs:sequence> 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, say <xs:element name="addresses"> <xs:sequence> <xs:element name="address" minOccurs="1" maxOccurs="2"> <xs:complexType> ... </xs:complexType> </xs:element> </xs:sequence> !-- specify a UNIQUE identify-definition-constraint specification using field xpath="address/@type" --! </xs:element> 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. Thanks, Bob Scalable XML Infrastructure IBM Thomas J. Watson Research Center Yorktown Heights, New York, USA http://www.research.ibm.com/XML Alexander Sherwood <asherwood@phs-ne To t.com> xmlschema-dev@w3.org Sent by: cc xmlschema-dev-req uest@w3.org Subject Help with choice model group! 06/15/2004 09:26 AM Greetings all, Given the following snippet: <addresses> <address street="" city="" state="" zip="" type="payment | mailing"/> </addresses> 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 THE COLLECTORS P: 813-283-4579 F: 301.664.6834 W: www.phs-net.com
Received on Tuesday, 15 June 2004 10:15:49 UTC