One Star

[resolved] Generate a dynamic file name for tFileOutputMSXML

Hi all.
I'm a newbie with Talend and I'm using a tFileOutpuMSXML to generate a XML file base on MySQL db filled from a list of files read from a folder (thanks to a tFileList).
I would like to generate a new XML file for each file found in tFileList. First I thought it will be possible to create a dynamic fileName for my MSXML output but it seem impossible (the fileName is generated at launch of th job, the solution would be to close the xml file, regenerate a new file name and reopen the file in a Java Row but I wasn't able to do it).
Is there a solution to create a new file with either a unique name for each file read by the FileList or dynamicaly set a file name for each of these files thanks to the manipulation I described but I wasn't able to do?
One Star

Re: [resolved] Generate a dynamic file name for tFileOutputMSXML

As it seemed that nobody had an answer about my request, I had to find another solution... and I did. Here is what I've done:

I created a tSetGlobalVar called, e.g., "myVar"
In a tJavaRow, I create a string called "myFileName" which is the dynamic part of the file name
In the same tJavaRow, I added the following code:

globalMap.put("myVar", myFileName.concat(".xml"));

I set the following file name for my tFileOutpuMSXML output: "C:/Users/cyrilp/Desktop/OutPutXML.xml"
I created a tFileCopy linked to my tFileOutputMSXML element thanks to a OnComponentOK event
I set the following parameters to my tFileCopy :
              - File name: "C:/Users/cyrilp/Desktop/OutPutXML.xml"
              - Destination folder: whatever you want
              - Rename: enabled
              - Destination file: ((String)globalMap.get("myVar"))
              - Remove source file: enabled
Then, it did the work! Smiley Happy
I don't know if it's the best way to solve a similar problem or if it would be possible to apply this on any case but it worked for me.
Four Stars

Re: [resolved] Generate a dynamic file name for tFileOutputMSXML

Hi BR,
Glad that you have found the solution on your own and thanks for posting the solution.