Kalyan
Kalyan

Reputation: 99

How to map specified pattern string into a xml using Mule data mapper

I have requirement to map specified patterned string to xml using data mapper in Mule.

Input payload (String) to Data mapper:

key1:value1,key2:value2

output payload (xml) from Data Mapper:

<control>
  <Parameter>
    <Key>key1</Key>
    <Value>value1</Value>
  </Parameter>
  <Parameter>
    <Key>key2</Key>
    <Value>value2</Value>
  </Parameter> 
</control>

Can someone give me the solution to achieve this using data mapper in mule?

Upvotes: 0

Views: 305

Answers (1)

V&#237;ctor Romero
V&#237;ctor Romero

Reputation: 5115

DataMapper has a script view (upper right-hand corner of the DataMapper console).

Create a mapping of the string to the key, then edit the mapping, by default it's written in the Mulee Expression Language. With it you can just split the value in two, and set to output values rathen than one. This will leave only one visual line.

You could also draw to mappings an then split on both, just taking value 0 in one and 1 in the other, this will be represented more beatifully in the visual editor but will perform worse.

Upvotes: 0

Related Questions