- From: Gary Fix <gary.fix@win-na.com>
- Date: Wed, 6 Oct 2004 11:32:49 -0700
- To: "Anli Shundi" <ashundi@tibco.com>, "Michael Kay" <mike@saxonica.com>
- Cc: <xmlschema-dev@w3.org>
Thank you both for your help!
:-)
-----Original Message-----
From: Anli Shundi [mailto:ashundi@tibco.com]
Sent: Wednesday, October 06, 2004 10:42 AM
To: Gary Fix
Cc: Michael Kay; xmlschema-dev@w3.org
Subject: Re: How ensure group elements exist and in any order
All groups may only be direct children of the model group! Make VINGroup
an element and keep its content unordered:
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="vehicle">
<xsd:complexType>
<xsd:choice>
<xsd:sequence>
<xsd:element ref="VINGroup"/>
<xsd:element ref="VIN" minOccurs="0"/>
</xsd:sequence>
<xsd:sequence>
<xsd:element ref="VIN"/>
<xsd:element ref="VINGroup" minOccurs="0"/>
</xsd:sequence>
</xsd:choice>
</xsd:complexType>
</xsd:element>
<xsd:element name="VIN" type="xsd:string"/>
<xsd:element name="VINGroup">
<xsd:complexType>
<xsd:all>
<xsd:element name="Body" type="xsd:string"/>
<xsd:element name="Make" type="xsd:string"/>
<xsd:element name="Model" type="xsd:string"/>
</xsd:all>
</xsd:complexType>
</xsd:element>
</xsd:schema>
The instances will have an extra element (level) called VINGroup... You
have to live with it.
-Anli
On 10/6/2004 1:30 PM, Gary Fix wrote:
> 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 18:33:22 UTC