0

I have something like this in an input XML

  <OrderText>
    <text_type>0012</text_type>
    <text_content>Text1</text_content>
  </OrderText>
  <OrderText>
    <text_type>ZT03</text_type>
    <text_content>Text2</text_content>
  </OrderText>

The above data I need to map after concatenating as the below schema

<Order>
    <Note>0012:Text1#ZT03:Text2</Note>
</Order>

Can anyone please help?

Dijkgraaf
  • 11,049
  • 17
  • 42
  • 54

2 Answers2

1

You can use the Value-Mapping Flattening functoid in a map, then feed the result of each into a Concatenate functoid to generate the result string. The map can be executed on a port or in an orchestration.

Tom W
  • 5,108
  • 4
  • 30
  • 52
1

I'm going to assume that your input actually has a Root node, as otherwise it is not valid XML.

<Root>
 <OrderText>
    <text_type>0012</text_type>
    <text_content>Text1</text_content>
  </OrderText>
  <OrderText>
    <text_type>ZT03</text_type>
    <text_content>Text2</text_content>
  </OrderText>
</Root>

Then all you need is a map like this

Map Image

With a String Concatenate functoid with

Input[0] = text_type
Input[1] = :
Input[2] = text_content
Input[3] = #

That goes into a Cumulative Concatenate

This will give you an output of

<Order>
  <Note>0012:Text1#ZT03:Text2#</Note> 
</Order>

Note: There is a extra # at the end, but you could use some more functoids to trim that off if needed.

Dijkgraaf
  • 11,049
  • 17
  • 42
  • 54