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

Re: How ensure group elements exist and in any order

From: Anli Shundi <ashundi@tibco.com>
Date: Wed, 06 Oct 2004 11:22:15 -0400
To: Michael Kay <mike@saxonica.com>
Cc: "'Gary Fix'" <gary.fix@win-na.com>, xmlschema-dev@w3.org
Message-id: <41640DA7.9010809@tibco.com>

But the all group would allow also none of the elements.

I think a choice is fine but as outlined in previous email is ambiguous.
In general the following should be enough:

(a, b?) | (b, a?)

You get at least one element and at most one of either a or b.  The 
number of permutations increases rapidly with more than two elements...


On 10/6/2004 11:00 AM, Michael Kay wrote:
> Provided each element can appear at most once, you can do this with xsd:all.
> The elements can be optional or mandatory, but not repeated (rather like
> attributes, really).
> Michael Kay
> http://www.saxonica.com/
>>-----Original Message-----
>>From: xmlschema-dev-request@w3.org 
>>[mailto:xmlschema-dev-request@w3.org] On Behalf Of Gary Fix
>>Sent: 06 October 2004 15:18
>>To: xmlschema-dev@w3.org
>>Subject: How ensure group elements exist and in any order
>>When a group of elements ("VINGroup") is present in my xslt 
>>file, I want to confirm that all members of the group are 
>>present but they may be in any order (sequence)...
>>Is there a way do this in the xsd?
>>This is what I have so far but it forces the VINGroup 
>>elements to be in a specific order...
>>thanks in advance,
>><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 
>>					<xsd:group 
>>ref="VINGroup" minOccurs="1" maxOccurs="1"/>
>>				</xsd:sequence>
>>				<!-- Case #2: VIN Only Supplied -->
>>				<xsd:sequence>
>>					<xsd:element 
>>ref="VehicleIdentificationNumber" 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: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>

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

Get Firefox! http://www.mozilla.org/products/firefox/
Received on Wednesday, 6 October 2004 15:22:58 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 7 January 2015 14:56:06 UTC