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

RE: How ensure group elements exist and in any order

From: Gary Fix <gary.fix@win-na.com>
Date: Wed, 6 Oct 2004 10:30:50 -0700
Message-ID: <EC0B8316E6B52349A8320C05B0E9CEA702DD8712@uniexcha.unigard.com>
To: "Anli Shundi" <ashundi@tibco.com>, "Michael Kay" <mike@saxonica.com>
Cc: <xmlschema-dev@w3.org>

The requirement is that I must have Either a VIN Or a VinGroup Or Both, And if I have a VinGroup, then All the elements of the VinGroup must be present, In Any Order...
The last part is where I'm having difficulty as I cannot use "xsd:all" in the group definition in place of "xsd:sequence"...My Xerces parser complains...
thanks!

Here's my xsd snippet so far but it requires the VinGroup elements to be in a sequence:

<xsd:element name="Vehicle">
	<xsd:complexType>
		<xsd:sequence>
			<xsd:choice minOccurs="1" maxOccurs="1">
				<!-- Case #1: VIN & Body/Make/Model Group Supplied -->
				<xsd:sequence>
					<xsd:element ref="VIN"/>
					<xsd:group ref="VINGroup" minOccurs="1" maxOccurs="1"/>
				</xsd:sequence>
				<!-- Case #2: VIN Only Supplied -->
				<xsd:sequence>
					<xsd:element ref="VIN" minOccurs="1"/>
				</xsd:sequence>
				<!-- Case #3: Body/Make/Model Group Only Supplied -->
				<xsd:sequence>
					<xsd:group ref="VINGroup" minOccurs="1" maxOccurs="1"/>
				</xsd:sequence>
			</xsd:choice>
		</xsd:sequence>
	</xsd:complexType>
</xsd:element>
<xsd:group name="VINGroup">
	<xsd:sequence>
		<xsd:element name="Body" type="xsd:string"/>
		<xsd:element name="Make" type="xsd:string"/>
		<xsd:element name="Model" type="xsd:string"/>
	</xsd:sequence>
</xsd:group>

-----Original Message-----
From: Anli Shundi [mailto:ashundi@tibco.com]
Sent: Wednesday, October 06, 2004 10:24 AM
To: Michael Kay
Cc: Gary Fix; xmlschema-dev@w3.org
Subject: Re: How ensure group elements exist and in any order


On 10/6/2004 11:54 AM, Michael Kay wrote:
>>But the all group would allow also none of the elements.
> 
> 
> Not if the element specifies minOccurs="1".
> 

but in that case an all group wouldn't allow only a or only b.  I 
thought that was a requirement.

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
     <xsd:element name="root">
         <xsd:complexType>
             <xsd:choice>
                 <xsd:sequence>
                     <xsd:element ref="a"/>
                     <xsd:element ref="b" minOccurs="0"/>
                 </xsd:sequence>
                 <xsd:sequence>
                     <xsd:element ref="b"/>
                     <xsd:element ref="a" minOccurs="0"/>
                 </xsd:sequence>
             </xsd:choice>
         </xsd:complexType>
     </xsd:element>
     <xsd:element name="a" type="xsd:string"/>
     <xsd:element name="b" type="xsd:string"/>
</xsd:schema>

-- 
Anli Shundi					ashundi@tibco.com
TIBCO Software Inc.				office: (919) 969-6518
www.tibco.com


Get Firefox! http://www.mozilla.org/products/firefox/
Received on Wednesday, 6 October 2004 17:31:24 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 5 February 2014 07:15:11 UTC