Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us to spark ideas for how to put the latest capabilities into action. Register here!
cancel
Showing results for 
Search instead for 
Did you mean: 
robster1
Contributor II
Contributor II

TDM : Mapping 1 XML file into Multiple csv files

Hey guys,

I'm having a trouble with this : I have an xml file that i want to split into multiple csv according to the sublevels that the input file has. Example:

input.xml could look like his.

 

<animal>

<animal_id>432</animal_id>

<animal_extra>

<animal_owner_name>Peter</animal_owner_name>

<animal_owner_lastname>Perez</animal_owner_lastname>

</animal_extra>

<animal_extra>

<animal_owner_name>Karen</animal_owner_name>

<animal_owner_lastname>Arts</animal_owner_lastname>

</animal_extra>

<extra_details>

<anyother_detail> RANDOM FACT </anyother_detail>

</extra_details>

</animal>

 

For this case i need to generate 3 output files which will be :

1) animal.csv

2) animal_extra.csv

3) extra_details.csv

The first one 1) will have only the common data shared for animal tag which will be animal_id. Only one row

 

The second one 2) will have the common data (animal_id) plus the animal_extra data, which in this case are 2 rows. As Example it should be:

 

animal_extra.csv

 

animal_id; animal_owner_name; animal_owner_lastname

432; Peter; Perez

432; Karen ; Arts

 

And the third one should have the common data (animal_id) plus the extra_details data

I wonder how can I map this into multiple csv files using Talend Data Mapper.

Assume that i have the XSD schema for the XML input file.

 

Thanks in advance!

 

Best Regards

Labels (4)
1 Reply
robster1
Contributor II
Contributor II
Author

*Edit 1 : Hi,As a solution I have been designing multiple structures for the csv outputs that I desire, and in the same way i've created the corresponding ThMaps (DM) for each of the structures. In my example I have 3 new structures (csv output) and 3 new data mappers. 

 

But, the case is that I have at least 67 levels (nested loop) in my original xml file. Hence i have to develop that many structures/DM components in my job . That's fine, because all the outputs should be different from each other. The problem here is in the Integration job. Because i don't want to make ~67 "on subjob ok" components in foreach levels in my original xml file.

 

So, the question is how can I make an 'iteration flow for each of the mappers. My goal is to just load the input once and then iterate over all the mappers that i have created and generate the corresponding outputfile.

 

Is that possible to do? 

 

 

 

Thanks in adavance again.