Changing message format

Use the Compute node to copy part of an input message to an output message. The results of such a copy depend on the type of input and output parsers involved.

Before you begin

If you are copying between unlike parsers, some attributes of the original message might be lost. To ensure that you copy every attribute, copy the message to the same parser.

Like parsers

About this task

Where both the source and target messages have the same folder structure at root level, a like-parser-copy is performed. For example:

SET OutputRoot.MQMD = InputRoot.MQMD;

This statement copies all the children in the MQMD folder of the input message to the MQMD folder of the output message.

Another example of a tree structure that supports a like-parser-copy is:

SET OutputRoot.XMLNS.Data.Account = InputRoot.XMLNS.Customer.Bank.Data;

To transform an input message in the MRM domain to an output message also in the MRM domain, you can use either the Compute or the Mapping node. The Mapping node can interpret the action that is required because it knows the format of both messages. Content Assist in the ESQL module for the Compute node can also use the message definitions for those messages. If the messages are not in the same namespace, you must use the Compute node.

To use Content Assist with message references, you must set up a project reference from the project containing the ESQL to the project containing the message set. For information about setting up a project reference, see Referencing resources in other libraries.

If both input and output messages are not in the MRM domain, you must use the Compute node and specify the structure of the messages yourself.

Unlike parsers

About this task

Where the source and target messages have different folder structures at root level, you cannot make an exact copy of the message source. Instead, the unlike-parser-copy views the source message as a set of nested folders terminated by a leaf name-value pair. For example, copying the following message from XML to MRM:

<Name3><Name31>Value31</Name31>Value32</Name3>

produces a name element Name3, and a name-value element called Name31 with the value Value31. The second XML pcdata (Value32) cannot be represented and is discarded.

The unlike-parser-copy scans the source tree, and copies folders, also known as name elements, and leaf name-value pairs. Everything else, including elements flagged as special by the source parser, is not copied.

An example of a tree structure that results in an unlike-parser-copy is:

SET OutputRoot.DFDL.Data.Account = InputRoot.XMLNSC.Data.Account;

If the algorithm used to make an unlike-parser-copy does not suit your tree structure, youmust further qualify the source field to restrict the amount of the tree that is copied.

Be careful when you copy information from input messages to output messages in different domains. You might code ESQL that creates a message structure or content that is not consistent with the rules of the parser that processes the output message. This action can result in an output message not being created, or being created with unexpected content. If you believe that the output message generated by a particular message flow does not contain the correct content, or have the expected form, check the ESQL that creates the output message, and look for potential mismatches of structure, field types, field names, and field values.

When copying trees between unlike parsers, it might be necessary to set the MessageSet, MessageType, and MessageFormat fields in the output Properties folder. Which fields need setting is dependent on the target parser. For example, if the target parser is MRM and the message set has been defined with a CWF format, the following commands are required to copy a message body created by the XMLNSC parser to a body owned by the MRM parser:
-- Copy message to the output, moving from XMLNSC to MRM domains
SET OutputRoot.MRM = InputRoot.XMLNSC.rootElement;
		
-- Set the CWF format for output by the MRM domain
SET OutputRoot.Properties.MessageType = '<MessageTypeName>';
SET OutputRoot.Properties.MessageSet = '<MessageSetName>';
SET OutputRoot.Properties.MessageFormat = 'CWF';