Four Stars

Talend Data Mapper xml input - looking up values in a separate loop

hi!  I have an xml file similar to the following:

 

<travelData>

  <Profiles>

    <Profile id=1 name="George">

    <Profile id=2 name="Henry">

    <Profile id=3 name="Bob">

    <Profile id=4 name="Eugene">

  <Profiles>

  <travelDetail>

    <travelSegment type="AIR" >

       <Price value="205.55" currency="USD">

       <ProfileReference id = 2/>

       <ProfileReference id=3/>

    </travelSegment>

  </travelDetail>

<travelData>

 

To create my JSON output, I loop over the travelSegments with the profileReferences nested, and build separate transactions for each profile reference like:

"travelData":[

{"type":"AIR",

  "name":"Henry",

  "price":205.55,

  "currency":"USD"

},

{"type":"AIR",

  "name":"Bob",

  "price":205.55,

  "currency":"USD"

}

 

I've got the thmap generating

"travelData":[

{"type":"AIR",

  "profileId":2,

  "price":205.55,

  "currency":"USD"

},

{"type":"AIR",

  "profileId":3,

  "price":205.55,

  "currency":"USD"

}

 

How do I lookup the profile reference id in the Profiles array to get the name corresponding to the profileReference id?  

 

I have tried many things including AgConcatFirstPresentValue, but it always grabs just the first value even if I filter the Profiles loop by the id = ProfileReference (at least for the ids included in the profileReference).  Is there a way to get just the profile with the id in the 2nd loop?

 

thank you!

1 ACCEPTED SOLUTION

Accepted Solutions
Nine Stars

Re: Talend Data Mapper xml input - looking up values in a separate loop

Hi,

 

I used a set variable:

Capture.PNG

Then I get this variable:

Capture.PNG

 

I uploaded my map.

 

Let me know if it meets your requirements.

 

Regards.

 

Eric

2 REPLIES
Nine Stars

Re: Talend Data Mapper xml input - looking up values in a separate loop

Hi,

 

I used a set variable:

Capture.PNG

Then I get this variable:

Capture.PNG

 

I uploaded my map.

 

Let me know if it meets your requirements.

 

Regards.

 

Eric

Four Stars

Re: Talend Data Mapper xml input - looking up values in a separate loop

Thank you!  It worked like a charm.