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

Announcements
Write Table now available in Qlik Cloud Analytics: Read Blog
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Probem: Talend is writing multiple xml rows into 1 xml file

Hello, 

I'm currently parsing a xml file containing multiple <Case> tags and creating 1 new xml file for each <Case> tag found.

 This works good so far, 1 row goes into the tXmlMap 29 rows go out (29 cases), but then when I want to write the xml files using a tFileOutputXml, I end up with 29 files (good) which all contain each and everyone of the 29 new files (bad).

So on one side the FileOutput create 1 File for each row, but on the other hand seems to add all rows into everyone of these files and I cannot understand why. 

 

Has anyone encountered something like this?

Labels (3)
1 Solution

Accepted Solutions
TRF
Champion II
Champion II

When you use tFlowToIterate, each field from the input flow is transformed into a global variable.

By default the variable name is the same as the field name preceded by the flow name such as "row1.CaseXml".

To initiate a new data flow from this or these global variables, you need to use tFixedFlowInput (or tIterateToFlow) in which you start by defining the desired schema, for example 1 field called CaseXml datatype Document. Then, assign each field a value issued from the corresponding global variable.

Here is how it could look like:

0683p000009MaB7.png

Here is how the job design:

0683p000009MaBH.png

View solution in original post

9 Replies
TRF
Champion II
Champion II

You should share your job design.

Anyway, after tXmlMap you should have something like:

tFlowToIterate-->tJava(build next filename)-->tFixedFlowInput(renew the data flow 1 row)--> tFileOutputXML

Anonymous
Not applicable
Author

Thanks, I dont quite understand you solution, 

so here are some Screenshots to provide more details on the problem.

First the structure of the job itself:

0683p000009Ma21.png

Then the Mapping (Note the source XML contains multiple, for example 29 cases)

0683p000009MaAY.png

And the Xml FileOutput (I would expect 29 files each containing 1 Case, instead i'm getting 29 files each containing 29 cases).

0683p000009MaAd.png

 

Can anyone give advice to why this happens or how I can fix this?

TRF
Champion II
Champion II

Questions:
- what's in the lookup?
- where do the context variables come from (as it seems this is the only dynamic part of filename)?
- can you share a capture with rows count (after the job has finished)?
Anonymous
Not applicable
Author

The Lookup and the context Variables could be ommitted, the lookup only holds specifications etc. that get pulled into the mapping via an id.

The Context Variables likewise get pulled from the same source xml to build the fileName for each row (which works correctly), I have also tried this with a static filename (ending up with one file contianing all 29 cases).

 

Here is a Screenshot with Rowcount.

0683p000009MaAi.png

TRF
Champion II
Champion II

Try the suggested design
tXmlMap--&gt;tFloToIterate(here, 1 created var will contain the target filename)--(iterate)--&gt;tFixedFlowInput(generate the flow for 1 case)--&gt;tFileOutputXML
This is a common design and it works when you want as many output files than rows in the input flow
Anonymous
Not applicable
Author

Okay that sounds promising, thank you.

 

But could you elaborate on how to generate the flow in the FixedFlowInput? 
Would I need to tempSave the row / case before the FlowToIterate or how can I access the rows coming out of the txmlMap in the FixedFlowInput Component?

 

Thanks

 

TRF
Champion II
Champion II

When you use tFlowToIterate, each field from the input flow is transformed into a global variable.

By default the variable name is the same as the field name preceded by the flow name such as "row1.CaseXml".

To initiate a new data flow from this or these global variables, you need to use tFixedFlowInput (or tIterateToFlow) in which you start by defining the desired schema, for example 1 field called CaseXml datatype Document. Then, assign each field a value issued from the corresponding global variable.

Here is how it could look like:

0683p000009MaB7.png

Here is how the job design:

0683p000009MaBH.png

Anonymous
Not applicable
Author

Thanks alot for that explanation. 

Anonymous
Not applicable
Author

I tried to implement this, but I ended up with 29 files all containing 1 of the 29 cases. 

So some improvement but somehow not working as expected. 

Can you maybe provide some more advice?