Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


RE: deriving restriction types

From: "Xan Gregg" <Xan.Gregg@---.--->
To: "gayathri veerarajan" <gaytri_v@-----.--.-->, <xmlschema-dev@--.--->
Date: 4/8/2004 9:05:00 AM
 >  I would like to know whether this is a valid restriction
 
<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>
 
> I want to derive a new complex type restricted from wineGrape where I =
expect the element   
> CabernetFrancGrape to appear at least once.
 
If you want CabernetFrancGrape to appear at least once, then the others =
can't appear at all,
so the restriction would be:
 
<xsd:complexType name="WineGrape_hasValue_CabernetFrancGrape">
   <xsd:complexContent>
     <xsd:restriction base="vin:WineGrape">
       <xsd:choice >
        <xsd:element ref="CabernetFrancGrape" minOccurs="1" =
maxOccurs="unbounded" /> 
     </xsd:choice >
  </xsd:restriction>
 </xsd:complexContent>
</xsd:complexType>
 
I'm guessing you originally meant something like
 
<xsd:complexType name="WineGrape">
 <xsd:choice minOccurs="0" maxOccurs="unbounded" >
  <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> 
 
To restrict it to require at least one CabernetFrancGrape, you might try
 
<xsd:complexType name="WineGrape"> 
<xsd:sequence> 

 <xsd:choice minOccurs="0" maxOccurs="unbounded">
  <xsd:element ref="WineGrape"  /> 
  <xsd:element ref="CabernetSauvignonGrape" /> 
  <xsd:element ref="ChardonnayGrape"  /> 
  <xsd:element ref="CheninBlancGrape"  /> 
  <xsd:element ref="ZinfandelGrape"  /> 
  <xsd:element ref="GamayGrape"  /> 
 </xsd:choice> 
 
 <xsd:element ref="CabernetFrancGrape"  />  
 
 <xsd:choice minOccurs="0" maxOccurs="unbounded" >
  <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:sequence> 
</xsd:complexType> 
 
But I don't know how that matches up with the explicit restriction =
rules, which some processors enforce.  I think the given restriction =
does obey the general restriction rule that the derived must validate a =
subset of the base.
 
xan 


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