NOTE:
These slides have not been updated since 2003. They have been superseded by the book
Anders Møller and Michael Schwartzbach, February 2006 |
THE XML REVOLUTION - TECHNOLOGIES FOR THE FUTURE WEB |
Types can be derived from other types:
<complexType name="car"> <complexContent> <extension base="n:vehicle"> <sequence> <element name="wheel" minOccurs="3" maxOccurs="4"/> </sequence> </extension> </complexContent> </complexType> |
<complexType name="small_car"> <complexContent> <restriction base="n:car"> <sequence> ... <element name="wheel" maxOccurs="3"/> </sequence> </restriction> </complexContent> </complexType> |
Subsumption:
<element name="myVehicle" type="n:vehicle"/> |
meaning that myVehicle elements are valid if they match the vehicle type.
Since car is derived from vehicle,
myVehicle elements are also valid if they match car
- provided that we add xsi:type="n:car" to the elements
(where xsi refers to http://www.w3.org/2001/XMLSchema-instance)
in the instance document.
Substitution groups - an alternative to type derivation:
<element name="myCar" type="n:car" substitutionGroup="n:vehicle"/> |
then we may always use myCar elements whenever myVehicle elements are required (without using xsi:type).
This is independent of the extension/restriction inheritance hierarchy! - car is not required to be declared as a sub-type of vehicle.
In addition to all this,
COPYRIGHT © 2000-2003 ANDERS MØLLER & MICHAEL I. SCHWARTZBACH |