Advanced XML with different loops

One Star

Advanced XML with different loops

Hello,
I have a scenario using XML files in which I have to set up something like this :
I have 3 data sources. Invoice_Header, Invoice_Line and Invoice_Line_Tax
My Invoice_Header schema is something like
ID,
TotalAmt,
Description
My Invoice_Line schema is something like
LineID,
HeaderID,
LineAmt
My Invoice_Line_Tax schema is something like
TaxID,
LineID,
TaxPerct,
TaxAmt
I would like to read the 3 separate tables and come up with one single XML at the end.
My problem is that I can't figure out a way to join the values because of different loops...for 1 invoice, I might have N lines, and for 1 Line I might have N Taxes
I've attached some handmade xml's that I'm working with to try to figure this out, there are the separated XML's and the final structure I would like to get to. It's something like this :
<Invoices>
<Invoice>
<ID/>
<TotalAmt/>
<Description/>
<InvoiceLines> /* Loop 1-N */
<Line>
<LineID/>
<LineAmt/>
<LineTaxes> /* Second Loop 1-N */
<Tax>
<TaxID/>
<TaxPerct/>
<TaxAmt/>
<Tax/>
</LineTaxes>
</Line>
</InvoiceLines>
</Invoice>
</Invoices>
Does anybody have any kind of ideas or something for me to try out ? I'm currently going for the tJava component and appending the strings for 3 different files into one...but that's obviously something I would like to avoid.
Thanks!
One Star

Re: Advanced XML with different loops

See http://www.talendforge.org/forum/viewtopic.php?id=7618 for an answer. To merge the output in your tree style you need to have the non loop part the same in the multiple roots so that they can be matched. I think there is a better example from Shong but I couldn't find it.

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

Tutorial

Introduction to Talend Open Studio for Data Integration.

Watch