MRM XML physical format: Handling xsi:type attributes

The prefix "xsi" is the namespace prefix used by convention for the XML Schema instance namespace. XML documents can contain elements that have an xsi:type attribute. This behavior provides an explicit data type for the element.

The MRM XML parser in sensitive to xsi:type attributes in the XML document. It modifies the data type of the element accordingly and adds the xsi:type attribute into the message tree.

The MRM XML writer is sensitive to xsi:type attributes in the message tree. It produces xsi:type attributes according to XML Wire Format message set property Output policy for xsi:type attributes. For example, xsi:type attributes can be removed, output on all elements or output according to rules specified in the SOAP standard.

If validation is enabled for an IBM® Integration Bus message flow, the validation logic is sensitive to xsi:type attributes and uses them to modify the validation of the element. It also validates the values of xsi:type attributes by using the rules described in XML Schema Part 1: Structures on the World Wide Web Consortium (W3C) website.

There are several important points to remember when parsing and writing XML documents that contain xsi:type attributes.

  • In order to detect and use xsi:type attributes, the message set must be namespace-enabled. To make a message set namespace-enabled, check the message set property Use namespaces.
  • If the value of the xsi:type attribute contains a namespace prefix, the prefix is expanded into a fully qualified URI by the MRM XML parser. If the same xsi:type attribute is produced later by the MRM XML writer, the same prefix is not automatically used for the value. You can control the prefixes used on output by using the Namespace settings list in the XML Wire Format message set properties. If no prefix is supplied, the XML writer assigns a default prefix.
  • If the xsi:type attribute of an element does not resolve to a type in the model, the behavior depends on whether MRM validation is enabled. If not validating, the MRM assumes that the type of the element is that declared in the model, and continue. If validating, a validation exception occurs.
  • If MRM validation is enabled, any required xsi:type attributes must be present in the message tree at the point when validation is performed. An xsi:type attribute is required when its value is different from the data type of the element as defined in the message model (this most commonly occurs when using XML Schema type derivation).
    • If validation is being performed on an input message, the MRM XML parser ensures that xsi:type attributes appear in the message tree, as described above.
    • If validation is being performed on an output message, you must ensure that the correct xsi:type attributes appear in the message tree. Ensure that any required xsi:type attributes are copied from input message tree to output message tree, or are explicitly created in the output message tree.
  • If you are using simple types that are xsd:unions, an xsi:type attribute can be used to direct the MRM XML parser when resolving the union.
  • If you have migrated from an earlier version of WebSphere® Message Broker that was not sensitive to xsi:type attributes, you might notice some changes of behavior. For example, xsi:type attributes are no longer treated as self-defining attributes, so they appear in the message tree with the name ‘type' instead of ‘@type'. If your message flow logic is sensitive to xsi:type attributes in the message tree, change your message flow to comply with the current behavior.

For more information about xsi:type attributes, see XML Schema Part 0: Primer on the World Wide Web Consortium (W3C) website.