Accessing the content of a message in the DFDL domain with namespace support enabled
Use namespaces where appropriate for messages that are parsed by the DFDL parser.
About this task
It is possible to create a DFDL schema file that has
a target namespace. All messages defined in that DFDL schema belong
to that namespace. When the DFDL parser parses one of the messages,
the namespace is included in the elements that are created in the
logical message tree. You must include the namespace when you code
the ESQL reference to the element. If you do not include the namespace,
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
model schema file. 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 constant 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.DFDL.ns01:MyMessage.ns01:Element1 = InputBody.ns01:MyMessage.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.DFDL.{ns02}:MyMessage.{ns02}:Element1 = InputBody.{ns02}:MyMessage.{ns02}:Element1;
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.DFDL.{ns03}:MyMessage.{ns03}:Element1 = InputBody.{ns03}:MyMessage.{ns03}:Element1;
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).
For more information about using namespaces with DFDL, see Namespaces in the Data Format Description Language (DFDL) v1.0 Specification.