The XML Schema language allows a type definition to be based on another type definition. In this way, a hierarchy of types can be constructed. This topic outlines the concepts of type inheritance, and highlights some important issues relating to substitution.
A full discussion of XML Schema type inheritance can be found on the World Wide Web Consortium (W3C) Web site, or in numerous books on XML schema.
A type is a restriction of its base type if elements of the derived type have a smaller range of legal values (or legal type members) than elements of the base type.
For example, a restriction of a complex type might reduce the number of occurrences of one of its type members, or might omit that type member completely.
Similarly, a restriction of a simple type might lower the Max Inclusive facet value, or raise the Min Inclusive facet value.
A type is an extension of its base type if elements of the derived type have a wider range of legal values (or legal type members) than elements of the base type.
For example, an extension of a complex type might add type members which were not present in the base type, or might allow a type member to repeat.
Similarly, an extension of a simple type must always be a complex type which is based on the simple type. (It is not possible to extend a simple type by widening its range of legal values)
Special rules apply to the derivation of simple types. A simple type cannot extend another simple type. This ensures that restrictions imposed by a simple type cannot be removed by deriving another simple type from it.
However, a complex type is allowed to extend a simple type. This does not affect the range of legal values of the simple type, but it does allow attributes to be added. The result of extending a simple type is always a complex type containing zero or more attributes.
The final attribute on a complex type can take three values, with the following effects:
XML Schema provides two different substitution mechanisms, both of which use type inheritance information to allow or disallow substitutions.
Element substitution is controlled by substitution groups, and element substitution can be blocked or allowed for extension and restriction by settings on either the element itself, or on the element's type.
Type substitution allows the type of the element to be defined within the instance document, using the xsi:type attribute on the element, so that the element's real type is not known until the element has been partly parsed. This mechanism can also be blocked or allowed based on the derivation method of the types involved.
Notices |
Trademarks |
Downloads |
Library |
Support |
Feedback
![]() ![]() |
ad10430_ |