Altova Mailing List Archives>Archive Index >xmlschema-dev Archive Home >Recent entries >Thread Prev - RE: How ensure group elements exist and in any order [Thread Next] Re: How ensure group elements exist and in any orderTo: Gary Fix <gary.fix@------.---> Date: 10/6/2004 9:42:00 AM
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@t...]
> Sent: Wednesday, October 06, 2004 10:24 AM
> To: Michael Kay
> Cc: Gary Fix; xmlschema-dev@w...
> 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@t...
TIBCO Software Inc. office: (919) 969-6518
www.tibco.com
Get Firefox! http://www.mozilla.org/products/firefox/
From mike@s... Wed Oct 06 18:17:01 2004
Received: from bart.w3.org ([128.30.52.40])
by frink.w3.org with esmtp (Exim 4.34)
id 1CFGLV-0002ca-V5
for | ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
