AnsweredAssumed Answered

Looping through a tag in Map

Question asked by vinaykumar.ananthula on Sep 27, 2017
Latest reply on Oct 4, 2017 by vinaykumar.ananthula

Dear Community Folks,
I came across below mapping requirement
My source xml is having this part.(presenting the part where i am facing the problem)

<custom-attribute attribute-id="XXX">AAA</custom-attribute>

<custom-attribute attribute-id="XXY">ABC</custom-attribute>

<custom-attribute attribute-id="XYZ">CBA</custom-attribute>

<custom-attribute attribute-id="ZXY">BBC</custom-attribute>

<custom-attribute attribute-id="YZX">CAB</custom-attribute>
On my target, i want to map the values of "custom-attribute" to different fields based on "attribute-id"
I used the logic like below to achieve it.
if(attrid == "XXX")
val1 = value;
else if(attrid == "XXY")
val2 = value;

maaped attrid and value to corresponding fields in source.

But when tested, Map creating the whole Target structure as many times as "custom-attrbute" tag there in the source.
For above example, its creating complete target sturcture 5 times.
what i am looking at is my logic need to loop all "custom-attribute" and pass in single document.
please help me in this regard.