- From: McBride, David <dmcbride@quicinc.com>
- Date: Wed, 25 Aug 2010 10:04:26 -0700
- To: "Cheney, Edward A SSG RES USAR" <austin.cheney@us.army.mil>, "xmlschema-dev@w3.org" <xmlschema-dev@w3.org>
Thanks, Austin.
Mr. Sperberg-McQueen helped me work out a solution, as follows:
<xsd:complexType name="abcd">
   <xsd:sequence>
     <xsd:element ref="tns:A" minOccurs="0" maxOccurs="unbounded"/>
     <xsd:choice>
       <xsd:element ref="tns:B"/>
       <xsd:element ref="tns:C"/>
       <xsd:element ref="tns:D"/>
     </xsd:choice>
     <xsd:choice minOccurs="0" maxOccurs="unbounded">
       <xsd:element ref="tns:A"/>
       <xsd:element ref="tns:B"/>
       <xsd:element ref="tns:C"/>
       <xsd:element ref="tns:D"/>
     </xsd:choice>
   </xsd:sequence>
  </xsd:complexType>
This achieves what I was after, which was:
1) Empty not allowed
2) No enforced sequence
3) A is optional, but only if B, C, or D
4) maxOccurs unbounded for A, B, C, and D
David
-----Original Message-----
From: xmlschema-dev-request@w3.org [mailto:xmlschema-dev-request@w3.org] On Behalf Of Cheney, Edward A SSG RES USAR
Sent: Wednesday, August 25, 2010 9:23 AM
To: xmlschema-dev@w3.org
Subject: Re: RE: Difficult logical relationship in complex type
Here is what I would do:
<xs:complexType>
  <xs:choice>
    <xs:choice>
      <xs:choice maxOccurs="unbounded">
        <xs:element ref="b"/>
        <xs:element ref="c"/>
        <xs:element ref="d"/>
      </xs:choice>
      <xs:element ref="a"/minOccurs="0" maxOccurs="unbounded"/>
    </xs:choice>
    <xs:choice maxOccurs="unbounded">
      <xs:element ref="b"/>
      <xs:element ref="c"/>
      <xs:element ref="d"/>
    </xs:choice>
  </xs:choice>
</xs:complexType>
Does that satisfy the requirements?  If that does not work please let me know what are the additional requirements I am sure I can find a way to make it work even if it does become a bit lengthy.
Austin
http://prettydiff.com/
Received on Wednesday, 25 August 2010 17:04:58 UTC