I am trying to map parts of the following source structure that has two sets of properties - one flat and one looped:
<root>
<flat>
<prop1>foo</prop1>
<prop2>bar</prop2>
...
</flat>
<loop>
<prop>
<qual>propA</qual>
<data>baz</data>
<more>blah</more>
</prop>
<prop>
<qual>propB</qual>
<data>qux</data>
<more>bhal</more>
</prop>
...
</loop>
</root>
Specifically, the flat part is the PO1 segment of an X12 850 EDI document, and the looping properties are the subsequent REF segments.
These should be mapped to a looping destination structure of key-value pairs that looks like this:
<root>
<props>
<prop>
<name>prop1</name>
<value>foo</value>
</prop>
<prop>
<name>propA</name>
<value>baz</value>
</prop>
</props>
</root>
I would like to map only some of the values, depending on the property name.
I have successfully mapped the flat portion to the destination using a table looping functoid and two table extractor functoids:
I have also successfully mapped the looping portion to the destination using a looping functoid and some equality checks to select only certain qual
values:
When I attempt to include both of these mappings at the same time, the map succeeds, but doesn't generate the combined output.
How I can I map both sections of the source document to the same looping section in the destination document?
Turns out I had oversimplified the problem; the flat group of properties actually contains the property name in one node and the value in another node. This is what they actually look like:
<flat>
<name1>prop1</name1>
<value1>foo</value1>
<name2>prop2</name2>
<value2>bar</value2>
...
</flat>
The concept of @Dijkgraaf's answer still works with this change if you use a Value Mapping (Flattening) functoid to get the property name from the correct location.
Usually the only way to solve this is with either
With your sample input that gives
<root>
<props>
<prop>
<name>prop1</name>
<value>foo</value>
</prop>
<prop>
<name>prop2</name>
<value>bar</value>
</prop>
<prop>
<name>propA</name>
<value>baz</value>
</prop>
<prop>
<name>propB</name>
<value>qux</value>
</prop>
</props>
</root>