Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: deriving restriction types

From: Xan Gregg <xan.gregg@---.--->
To: gayathri veerarajan <gaytri_v@-----.--.-->
Date: 4/12/2004 4:23:00 AM
I'm not sure your base type does what you expect, since it doesn't seem  
to fit with the derived types you want.  Your base type:

<xsd:complexType name="WineGrape">
  <xsd:choice>
   <xsd:element ref="WineGrape" minOccurs="0" maxOccurs="unbounded" />
   <xsd:element ref="CabernetFrancGrape" minOccurs="0"  
maxOccurs="unbounded" />
   <xsd:element ref="CabernetSauvignonGrape" minOccurs="0"  
maxOccurs="unbounded" />
   <xsd:element ref="ChardonnayGrape" minOccurs="0"  
maxOccurs="unbounded" />
   <xsd:element ref="CheninBlancGrape" minOccurs="0"  
maxOccurs="unbounded" />
   <xsd:element ref="ZinfandelGrape" minOccurs="0" maxOccurs="unbounded"  
/>
   <xsd:element ref="GamayGrape" minOccurs="0" maxOccurs="unbounded" />
  </xsd:choice>
</xsd:complexType>

What instance content do you want to accept?

valid: <WineGrape/>
valid: <WineGrape/><WineGrape/><WineGrape/>
valid: <ZinfandelGrape/><ZinfandelGrape/>
valid:  
<CabernetFrancGrape/><CabernetFrancGrape/><CabernetFrancGrape/ 
 ><CabernetFrancGrape/>

invalid: <ZinfandelGrape/><CabernetFrancGrape/>
invalid: <ChardonnayGrape/><CabernetFrancGrape/><ChardonnayGrape/>

The last two would be valid with my suggested change, but I can't tell  
if that is what you want. It's a matter of repeating the choice among  
grapes or repeating each grape after making the choice once.

xan

On Apr 10, 2004, at 7:13 AM, gayathri veerarajan wrote:

> Thanks for ur reply Sir.I orginally did not mean this way.
>
> <xsd:complexType name="WineGrape">
>  <xsd:choice minOccurs="0" maxOccurs="unbounded" > <!--it is just  
> xsd:choice -->
>   <xsd:element ref="WineGrape"  />
>   <xsd:element ref="CabernetFrancGrape"  />
>   <xsd:element ref="CabernetSauvignonGrape" />
>   <xsd:element ref="ChardonnayGrape"  />
>   <xsd:element ref="CheninBlancGrape"  />
>   <xsd:element ref="ZinfandelGrape"  />
>   <xsd:element ref="GamayGrape"  />
>  </xsd:choice>
> </xsd:complexType>
>
> it is just <xsd:choice> ,since I would be referencing this type in   
> two different cases as follows
>
> <xsd:complexType name="Wine">
>   <xsd:sequence>
> 	<xsd:element name="madeFromGrape" type="WineGrape" minOccurs="0"  
> maxOccurs="unbounded"/>
>   </xsd:sequence>
> </xsd:complexType>
>
>
> <xsd:complexType name="Zinfandel">
>   <xsd:sequence>
> 	<xsd:element name="madeFromGrape" type="WineGrape" minOccurs="0"  
> maxOccurs="1"/>
>   </xsd:sequence>
> </xsd:complexType>
>
> since maxOccurs  is set to "1" for the element "madeFromGrape" as above
> When we consider the following Wine type the maxOccurs I prefer to  
> have <xsd:choice> as a generalised one.
>
>
> Now I would like to derive a restricted Wine as folows
>
> <xsd:complexType name="StEmilion">
>  <xsd:complexContent>
>    <xsd:restriction base="Wine">
>      <xsd:sequence>
> 	<xsd:element name="madeFromGrape" type="CabernetFrancGrape"  
> minOccurs="0" maxOccurs="unbounded"/>
>      </xsd:sequence>
>    </xsd:restriction>
>   </xsd:
>   </xsd:complexType>
>
> and cabernetFrancGrape is derived from WineGrape. my requirement is  
> that the element madeFromGrape should have the subelement  
> CabernetFrancGrape and also have any other elements.
>
> <xsd:complexType name="CabernetFrancGrape">
> - <xsd:complexContent>
> -   <xsd:restriction base="vin:WineGrape">
> -     <xsd:sequence>
>         <xsd:element ref="CabernetFrancGrape" minOccurs="1"  
> maxOccurs="unbounded" />
>         <xsd:element ref="CabernetSauvignonGrape" minOccurs="0"  
> maxOccurs="unbounded" />
>         <xsd:element ref="ChardonnayGrape" minOccurs="0"  
> maxOccurs="unbounded" />
>         <xsd:element ref="CheninBlancGrape" minOccurs="0"  
> maxOccurs="unbounded" />
>         <xsd:element ref="ZinfandelGrape" minOccurs="0"  
> maxOccurs="unbounded" />
>         <xsd:element ref="GamayGrape" minOccurs="0"  
> maxOccurs="unbounded" />
>      </xsd:sequence>
>   </xsd:restriction>
>  </xsd:complexContent>
>
> but sequence doesn't seem to work. is there any other way of doing  
> this.
> I cannot do as u have suggested,since type WineGrape is a general one  
> and each time I have to pose different restriction.
> could u suggest me any other way of doing this Sir.
>
> thank u,
> V.Gayathri.

From xan.gregg@j...  Mon Apr 12 08:42:28 2004
Return-Path: <xan.gregg@j...>
X-Original-To: xmlschema-dev@l...
Delivered-To: xmlschema-


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