Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: Help with choice model group!

From: Bob Schloss <rschloss@--.---.--->
To: Alexander Sherwood <asherwood@-------.--->
Date: 6/15/2004 6:03:00 AM




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@w...                
             Sent by:                                                   cc 
             xmlschema-dev-req                                             
             uest@w...                                           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



From nobody@w...  Tue Jun 15 10:21:44 2004
Return-Path: <nobody@w...>
X-Original-To: xmlschema-dev+aa@l...
Deliver


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent