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

Re: A question on "Restriction"

From: Henry S. Thompson <ht@cogsci.ed.ac.uk>
Date: 15 Dec 2000 09:46:41 +0000
To: Yimin Zhu <yzhu@citadon.com>
Cc: "'xmlschema-dev@w3.org'" <xmlschema-dev@w3.org>
Message-ID: <f5b4s06j9tq.fsf@cogsci.ed.ac.uk>
Yimin Zhu <yzhu@citadon.com> writes:

> If I have a complextType A containing two sub elements B and C.
> <complexType name="A">
> 	<complexContent>
> 		<element name="B" type="string"/>
> 		<element name="C" type="string"/>
> 	</complexContent>
> </ComplexType>

Not valid as written, should be

 <complexType name="A">
  <element name="B" type="string"/>
  <element name="C" type="string"/>

> Now I wish to define an element E, which is inherited from A. Also, E can
> only have B in its content model. Can I do it by using restriction as
> following?

> <element name="E">
> 	<complexType>
> 			<xsd:complexContent>
> 				<xsd:restriction base="A">
> 					<xsd:all>
> 						<xsd:element name="B"
> type="xsd:string"/>
> 					</xsd:all>
> 				</xsd:restriction>
> 			</xsd:complexContent>
> 	</complexType>
> </element>

Again, typos corrected, and assume prefix 'my' for targetNamespace:

<element name="E">
     <restriction base="my:A">
         <element name="B" type="string"/>

No, this is not valid.  Restriction can only eliminate optional parts
of content models, and the 'C' element in the 'A' type was not

  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 Friday, 15 December 2000 04:46:44 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 23:14:48 UTC