Mapping Hierarchical (Structured) XML to Flat XML
To illustrate how to map a hierarchical EDI structure to a target flat structure, I’ll work with the DTM field in an 867. Assume the following rules:
1. If the DTM01 node = 003, map DTM02 to one node in target schema.
2. If the DTM01 node = 004, map DTM02 to a different node in target schema.
By default, I know that I need to place two “Equals” functoids and two “Value Mapping” functoids to get the values across, as shown here:

Incorrect Mapping (checks only the first occurance of DTM)
With the incorrect output (shown here) showing only one of the targeted nodes. This is because the map is not looping through all of the source DTM nodes.

Output of Incorrect Mapping
Knowing that there always two or more DTM nodes in the source, the map will need to be forced to loop through all occurances. This can be done by adding a “Loop” functoid, with the input being the root DTM node, and the output being both of the desired output nodes. This map looks as follows:

Correct Mapping (with Loop Functoid)
This will cause the map to loop through all occurances of the source. Only those occurances which match the “Equals” logic will be mapped across. The correct output is shown here:

Result