RE: RE: Difficult logical relationship in complex type
"McBride, David" <[email protected]>
| Newsgroups | gmane.text.xml.schema.devel |
|---|---|
| Message-ID | <9D1BAF3185DB1C4AB699D189522340EC06256D22D9@NASCLEXMB01.na.qualcomm.com> |
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: [email protected] [mailto:[email protected]] On Behalf Of Cheney, Edward A SSG RES USAR
Sent: Wednesday, August 25, 2010 9:23 AM
To: [email protected]
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/