Accessing the content of a message in the MRM domain with namespace support enabled
Use namespaces where appropriate for messages that are parsed by the MRM parser.
About this task
When you want to access elements of a message and namespaces
are enabled, you must include the namespace when you code the ESQL
reference to the element. If you do not do so, the integration node
searches the no target
namespace. If the element
is not found in the no target
namespace, the integration
node searches all other known namespaces in the message dictionary
(that is, within the deployed message set). For performance and integrity
reasons, specify namespaces wherever they apply.
The most efficient way to refer to elements when namespaces are enabled is to define a namespace constant, and use this in the appropriate ESQL statements. This technique makes your ESQL code much easier to read and maintain.
Define a constant using the DECLARE NAMESPACE statement:
DECLARE ns01 NAMESPACE 'http://www.ns01.com'
.
.
SET OutputRoot.MRM.ns01:Element1 = InputBody.ns01:Element1;
ns01
is interpreted correctly as a namespace
because of the way that it is declared.
You can also use a CHARACTER variable to declare a namespace:
DECLARE ns02 CHARACTER 'http://www.ns02.com'
.
.
SET OutputRoot.MRM.{ns02}:Element2 = InputBody.{ns02}:Element2;
If you use this method, you must surround the declared variable with braces to ensure that it is interpreted as a namespace.
If you are concerned that a CHARACTER variable might get changed, you can use a CONSTANT CHARACTER declaration:
DECLARE ns03 CONSTANT CHARACTER 'http://www.ns03.com'
.
.
SET OutputRoot.MRM.{ns03}:Element3 = InputBody.{ns03}:Element3;
You can declare a namespace, constant, and variable within a schema, module, or function.