Four Stars DPE
Four Stars

Need to Split xml

HI All,

I am new to Talend, I have a requirement as I have to read data from Header and Details table and read those data into xml file. my Details table can have multiple records for a particular Header data.While sending the XML, I need to split the XML file based on the recors (for each Header records, need to send separate file and assign the file name from the field from Header table named XmlFile name as well).

My table data looks like

Table Structure.JPG

I have used a Job with tMssqlInput --> tMap--> tAdvancedFileOutputXML.JobDesign.JPG

 I have created a metadata for the xml file and given the header node as group element and Line element as loop element. and set the split property of the tAdvancedfile outputxml with 1 record I am getting the output as AfterSplitwith1Rec.JPG

 

 

if I will not set the split property the out put will be BeforeSplit.JPG

 

 

But I need the out put as below:ExpectedXML.JPG

 

 

could you some one please help me to achive this.

Thanks in advance

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Six Stars

Re: Need to Split xml

First try to extract only header table internalid using tmssqlinput.
Connect it to tFlowtoIterate component and store the internal id in a global variable.

Take out iterate link from tFlowToIterate and connect to your tMsSqlInput_2 (as shown in your job)component ,where you can use parameterised internal id for joinng query with detail table.

Also use the parameterized variable for your output file name. No need to use split property.
2 REPLIES
Six Stars

Re: Need to Split xml

First try to extract only header table internalid using tmssqlinput.
Connect it to tFlowtoIterate component and store the internal id in a global variable.

Take out iterate link from tFlowToIterate and connect to your tMsSqlInput_2 (as shown in your job)component ,where you can use parameterised internal id for joinng query with detail table.

Also use the parameterized variable for your output file name. No need to use split property.
Four Stars DPE
Four Stars

Re: Need to Split xml

Hi Chirgal,

Yes, its worked for me...  Thanks a lot for your help.