Unique Filename by a Value of an XML - Node

Five Stars

Unique Filename by a Value of an XML - Node

Hi, 

 

I create a Job which list XML -Files and now I want a unique Filename out of a Value of a Node from the XML. 
job1.PNG

If I run this Job, the output for the first File ist NULL.xml and the Others are right and  the Content of the Files are in the next File not in the File which the Number has.
job1.PNG
I use the tJavaRow for to set a Variable and to check is the Variable != null 

 

//own script for order_id
output_row.ORDER_ID = input_row.ORDER_ID;
if(output_row.ORDER_ID != null){
	globalMap.put("name", output_row.ORDER_ID);
	System.out.printf("Dies ist der Output: " + output_row.ORDER_ID);
}else{
	globalMap.put("name", "error");
};
//end

I think, if I run the job, the Variabale was set on runtime and is null a the first. How can I solve the Problem? 

Thanks for help. 

Greetings Chris Smiley Very Happy

Forteen Stars TRF
Forteen Stars

Re: Unique Filename by a Value of an XML - Node

Files are created each time a new iteration starts, so when the subjob starts, the tJavaRow has not been yet executed and the "name" variable is null.
Use tFlowToIterate then tIterateToFlow after tJavaRow to solve your case.

TRF
Five Stars

Re: Unique Filename by a Value of an XML - Node

Hey TRF, 

thanks for the fast Help,

if I use tJavaRow -->tFlowToIterate-->tIterateToFlow-->tAdvancedFileOutputXML it creates only one File and write alle the content of the InputFiles in it.

 

job1.PNG

Five Stars

Re: Unique Filename by a Value of an XML - Node

Has Nobody a solution for me Smiley Sad 

Community Manager

Re: Unique Filename by a Value of an XML - Node

Hi
Can you show an example of input XML file? How many nodes could be extracted from the input XML file?

Regards
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
Five Stars

Re: Unique Filename by a Value of an XML - Node

Hi Shong, the nodes are variable in the input File. My first problem was that I can´t set a global Variable with content of a row. At the first iteration the unique file name which I use the global Variable was null and the Content was not in the correct file. So I use the solution of TRF, it generates one File with all the Content of the input files Smiley Sad

Regards Chris