W3C home > Mailing lists > Public > xmlschema-dev@w3.org > November 2000

Re: [Moderator Action] Question related to XML Schema

From: Henry S. Thompson <ht@cogsci.ed.ac.uk>
Date: 30 Nov 2000 09:57:45 +0000
To: "Rishi Chandra" <rishi_chandra@intersolutions.stpn.soft.net>
Cc: <xmlschema-dev@w3.org>
Message-ID: <f5bpujd6aue.fsf@cogsci.ed.ac.uk>
"Rishi Chandra" <rishi_chandra@intersolutions.stpn.soft.net> writes:

> I wanted to know whether in XML-Schema there is any way in which a member
> (an element defined in a complexType) can be extended/restricted (basically
> sub-typed)? I wanted to define few types (which will have elements of some
> other types) and then keep on evolving sub-types by extension and
> restriction.

Sorry for slow reply, I've been on the road (at XML Schema meetings :-).

If I've understood correctly, the answer is yes.

For example, given 

 <xs:complexType name='big'>
  <xs:sequence>
   <xs:element name='sub1' type='sub1Type'/>
   . . .
  </xs:sequence>
 </xs:complexType>

 <xs:complexType name='sub1Type'>
  <xs:choice>
   <xs:element ref='part1'/>
   <xs:element ref='part2'/>
   <xs:element ref='part3'/>
  </xs:choice>
 </xs:complexType>

then the following is cool

 <xs:complexType name='little'>
  <xs:complexContent>
   <xs:restriction base='big'>
    <xs:sequence>
     <xs:element name='sub1' type='sub1TypeTwo'/>
     . . .
    </xs:sequence>
   </xs:restriction>
  </xs:complexContent>
 </xs:complexType>

 <xs:complexType name='sub1TypeTwo'>
  <xs:complexContent>
   <xs:restriction base='sub1Type'>
    <xs:choice>
     <xs:element ref='part1'/>
     <xs:element ref='part2'/>
    </xs:choice>
   </xs:restriction>
  </xs:complexContent>
 </xs:complexType>

ht
-- 
  Henry S. Thompson, HCRC Language Technology Group, University of Edinburgh
          W3C Fellow 1999--2001, part-time member of W3C Team
     2 Buccleuch Place, Edinburgh EH8 9LW, SCOTLAND -- (44) 131 650-4440
	    Fax: (44) 131 650-4587, e-mail: ht@cogsci.ed.ac.uk
		     URL: http://www.ltg.ed.ac.uk/~ht/
Received on Thursday, 30 November 2000 04:57:50 GMT

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