W3C home > Mailing lists > Public > xmlschema-dev@w3.org > December 2004

RE: Restricting child elements in a schema

From: Michael Kay <mike@saxonica.com>
Date: Wed, 1 Dec 2004 21:39:02 -0000
To: "'Dilpa Mehta'" <dilpamehta@hotmail.com>, <xmlschema-dev@w3.org>
Message-Id: <E1CZcBn-0003KH-00@ukmail1.eechost.net>
You can define one complex type as a restriction of another, for example
 
 <xs:complexType name="IndivNameType" mixed="true">
  <xs:choice minOccurs="0" maxOccurs="unbounded">
   <xs:element name="NamePart" type="xs:string"/>
   <xs:element name="IndNameVariation" type="xs:string"/>
  </xs:choice>
  <xs:attribute name="Type" type="xs:string"/>
  <xs:attribute name="Method" type="xs:string"/>
 </xs:complexType>
 
 <xs:complexType name="IndivNameVariationType" mixed="true">
     <xs:complexContent>
        <xs:restriction base="IndivNameType">
          <xs:choice minOccurs="0" maxOccurs="unbounded">
           <xs:element name="NamePart" type="xs:string"/>
          </xs:choice>
      </xs:restriction>
  </xs:complexContent>        
 </xs:complexType>
 
Where exactly are you having problems?
 
You can't restrict and extend at the same time: you have to do this in two
steps.
 
Michael Kay


  _____  

From: xmlschema-dev-request@w3.org [mailto:xmlschema-dev-request@w3.org] On
Behalf Of Dilpa Mehta
Sent: 01 December 2004 19:19
To: xmlschema-dev@w3.org
Subject: Restricting child elements in a schema


Hi,

I have 2 schemas , schema A and schema B. I import schema A into schema B so
that i could reuse some complex types of schema A. I extend a that complex
type in schema B by using <<xs:extension base>. 

However, for few elements that i want to reuse, i also want to add
restriction like make them required as they are not required in the source
schema and i want this element to appear only once (the one i define in
schema B).

This is urgent , can someone help?

Thanks




 

  _____  

The all-new MSN Search. Get fast and precise results. Try it now!
<http://g.msn.com/8HMAENIN/2746??PS=47575>  
Received on Wednesday, 1 December 2004 21:39:07 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 11 January 2011 00:14:48 GMT