- From: Xan Gregg <xan.gregg@jmp.com>
- Date: Mon, 12 Apr 2004 08:23:11 -0400
- To: gayathri veerarajan <gaytri_v@yahoo.co.in>
- Cc: xmlschema-dev@w3.org
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.
Received on Monday, 12 April 2004 08:25:38 UTC