You can exploit namespace support for messages that are parsed by the MRM parser.
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 broker searches the notarget namespace. If the element is not found in the notarget namespace, the broker 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.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.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.Element3 = InputBody.{ns03}:Element3;
You can declare a namespace, constant, and variable within a module or function. However, you can declare only a namespace or constant in schema scope (that is, outside a module scope).