Substitution groups in the message model

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 appear 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.

Tip: If your messages are never rendered as XML, or if you have a simple message model, use a complex type or a group with Composition set to Choice, instead of using substitution groups.

Elements

Head elements
A head element is simply an element that can be substituted. When a message is parsed, one of its member elements can appear in place of the head element without causing a validation error.
Abstract elements
An abstract element is a head element which must be substituted. The 'abstract' attribute on the element indicates this. Typically, abstract elements have other elements in their substitution group - otherwise they are of little use. Wherever an abstract element appears in a message definition, a member of its substitution group must appear instead.

Attributes

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 element's type cannot substitute for the element.
  • If the block attribute contains extension, an element that is based on an extension of the element's type cannot substitute for the element.
  • If the block attribute contains substitution, an element that is a member of the element's substitution group cannot substitute 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 element's substitution group. 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 element's type 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 element's type 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 those shown for the block attribute on an element above. An element that is a member of a substitution group can only substitute 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.
Related concepts
XML Schema and the message model
Schema restrictions in the message model
Message model objects: type inheritance
Notices | Trademarks | Downloads | Library | Support | Feedback

Copyright IBM Corporation 1999, 2009Copyright IBM Corporation 1999, 2009.
Last updated : 2009-01-07 15:21:02

ad10440_