W3C home > Mailing lists > Public > xmlschema-dev@w3.org > October 2001

Re: Inheritance

From: Henry S. Thompson <ht@cogsci.ed.ac.uk>
Date: 22 Oct 2001 11:51:24 +0100
To: "Tim Galle" <timgalle@cyberdude.com>
Cc: <xmlschema-dev@w3.org>
Message-ID: <f5b7ktokkwj.fsf@cogsci.ed.ac.uk>
"Tim Galle" <timgalle@cyberdude.com> writes:

> Hello everyone,
> Is the following possible with XML-schemas:
> In Schema A I define a structure (element construction) and 2 kinds of
> attributes: a kind that can not be redefined (Final) and one that can be
> redifined (Overridable)
> Now Schema B must take everything from A, structure and attributes.  It may
> extend the structure with new elements, and add new attributes to elements
> defined in A.  It may redefine overridable attributes from A (Polymorhing),
> but it may not redefine final attributes.

In brief, yes, you can do this.

You have to do it attribute-by-attribute, however:

<xs:schema targetNamespace="urn:foo1" xmlns:my="urn:foo1">
 <xs:complexType name="struct1">
  <xs:attribute name="final1" type="my:ft1"/>
  <xs:attribute name="final2" type="my:ft2"/>
  <xs:attribute name="final3" type="my:ft3"/>
  <xs:attribute name="over1" type="xs:decimal"/>
  <xs:attribute name="over2" type="xs:string"/>
 <xs:simpleType name="ft1" final="#all">
  <xs:restriction base="xs:decimal"/>
 <xs:simpleType name="ft2" final="#all">
  <xs:restriction base="xs:string"/>
 <xs:simpleType name="ft3" final="#all">
  <xs:restriction base="xs:boolean"/>

<xs:schema targetNamespace="urn:foo2" xmlns:core="urn:foo1"
 <xs:import "urn:foo1"/>

 <xs:complexType name="extStruct1">
   <xs:extension base="core:struct1">
      . . .

 <xs:element name="xyzzy">
     <xs:restriction base="ym:extStruct1">
      <xs:attribute name="over1" type="xs:integer"/>

This is OK.  If you tried to restrict "final1" instead of "over1",
you'd get an error.

Hope this helps,

  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 Monday, 22 October 2001 06:50:38 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 7 January 2015 14:55:53 UTC