Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: How ensure group elements exist and in any order

From: Anli Shundi <ashundi@-----.--->
To: 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


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent