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

Highlighted
Five 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!


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


All 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

Five Stars

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

Thank you!  It worked like a charm.  

Calling Talend Open Studio Users

The first 100 community members completing the Open Studio survey win a $10 gift voucher.

Start the survey

2019 GARNER MAGIC QUADRANT FOR DATA INTEGRATION TOOL

Talend named a Leader.

Get your copy

OPEN STUDIO FOR DATA INTEGRATION

Kickstart your first data integration and ETL projects.

Download now

What’s New for Talend Summer ’19

Watch the recorded webinar!

Watch Now

Best Practices for Using Context Variables with Talend – Part 4

Pick up some tips and tricks with Context Variables

Blog

How Media Organizations Achieved Success with Data Integration

Learn how media organizations have achieved success with Data Integration

Read

Downloads and Trials

Test drive Talend's enterprise products.

Downloads