Substitution groups are
an XML Schema feature that provides a way of substituting one element
for another in an XML message.
A substitution group is a list of global elements that can be present
in place of another global element, called the head element.
A substitution group is defined by setting the substitution group property on one
global element (the member element) to point at another
global element (the head element). This adds the member
element to the substitution group of the head element.
- Head elements
- A head element is an element that can be substituted. When a message
is parsed, one of its member elements can be present in place of the
head element without causing a validation error.
- Abstract elements
- An abstract element is a head element which must be substituted,
and is indicated by the 'abstract' attribute on the element. Typically,
abstract elements have other elements in their substitution group,
otherwise they are of little use. Wherever an abstract element is
present in a message definition, a member of its substitution group
must be present instead.
- The block attribute on
elements
- The block attribute on
an element limits the set of global elements that can substitute for
the element. The block attribute
can take any subset of the values restriction, extension, substitution, or all.
- If the block attribute
contains restriction,
an element that is based on a restriction of the type of the element
cannot be substituted for the element.
- If the block attribute
contains extension,
an element that is based on an extension of the type of the element
cannot be substituted for the element.
- If the block attribute
contains substitution,
an element that is a member of the substitution group of the element
cannot be substituted for the element.
- If the block attribute
contains all, all of
the above limits apply.
- The final attribute on
elements
- The final attribute on
an element limits the set of global elements that can be a member
of the substitution group of the element. The final attribute can take any subset
of the values restriction, extension, or all.
- If the final attribute
contains restriction,
an element that is based on a restriction of the type of the element
cannot be in the substitution group of the element.
- If the final attribute
contains extension,
an element that is based on an extension of the type of the element
cannot be in the substitution group of the element.
- If the final attribute
contains all, both of
the above limits apply.
- The block attribute on
complex types
- The block attribute on
a complex type limits the set of other types that can substitute for
that type. The block attribute
can take values restriction, extension, or all. The meanings for these values
are the same as the values that are shown for the block attribute
on an element. An element that is a member of a substitution group
can substitute only for the head element if its type is compatible
with the block attribute on the type of the head element.
- Default block and final attributes
- A default for the block and final attributes can be set at the
message definition file level. If a default for one or both of these
attributes has been set and the relevant block or final attribute has not been set
at the object level, the default setting is used for that object.
You can override the default setting at the object level.