Re: Derivation by restriction wrt to type inheritance

"Martin Bernauer" <bernauer@dke.uni-linz.ac.at> writes:

> Mike Leditschle pointed out that there was a thread "Restriction of complex
> types by changing minOccurs" dealing with somewhat the same sort of problem.
> Thank you Henry and Mike, I now see that the XML Schema Spec forces the type
> of a content particle of a complex type derived by restriction to have
> a restricted type of its complex type base type.
> 
> Nevertheless I don't see the rationale behind it, as in oo pardigm and many
> programming languages it is perfectly valid to derive a type R from a base
> type B and to redefine the type of a structural attribute b of the base type
> in the subtype.
> Actually there wouldn't be any problem, if XML Schema allowed me to redefine
> the type of a particle in derivation by extension. However, it is only
> possible when I derive by restriction, forcing me to restrict the particle's
> type too. Could someone motivate this decision?

We started with some very simple invariants:

Restriction:
 instances of a restricted type is always an instances of the base type;

Extension:
 instances of an extended type always contain an instance of the base
 type as a prefix.

The latter is indeed modelled on sub-classing in OO languages.  Could
you clarify your counter-example?  Certainly in C++ for instance basic
derivation simply adds new instance variables/methods, it doesn't
change those of the base, does it?  That's why you can always treat a
pointer to an instance of the derived as an instance of the base,
because on the stack it is actually realised as base+extras.

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 Friday, 23 November 2001 05:12:36 UTC