tAdvancedFileOutputXML creates empty files

Highlighted
One Star

tAdvancedFileOutputXML creates empty files

Hi,

I've searched for a solution, but didn't find any in the forum.

Here is my case :

I have a tFileList, iterating over XML files (and sending them to a tFileInputXML component).
The tFileInputXML component sends each to a tMap. This tMap has several outputs, all of them going directly to a dedicated tAdvancedOutputXML component.
Depending on some source nodes, one output or another is selected.

My problem is with the XML files generated by the tAdvancedOutputXML : even if any node match the rule declared into a transformation of the tMap, a file is generated, containing only the header definition of the XML file (I mean <?xml ... ?>).

Of course, I've checked "do not generate empty file"

I do not want to have a file if there is nothing written in it. How can I do ?
Four Stars

Re: tAdvancedFileOutputXML creates empty files

Wow, I never noticed the "Do not generate empty file" option. I needed something like this for tFileOutputExcel, though I was told for our project to generate a file even if we dont import results.
One Star

Re: tAdvancedFileOutputXML creates empty files

Unfortunately, it DOES create empty files in my case.
Is there any workaround to prevent this ?
Four Stars

Re: tAdvancedFileOutputXML creates empty files

Try to do something to stop the flow to the output components if there isnt anything. Perhaps a tFilterRow or a tJava component...Im curious to see if there is a way to stop the flow altogether if there isnt any data to pass through.

Also, you can try to use the tDeleteFile component if you check the file for any data...
One Star

Re: tAdvancedFileOutputXML creates empty files

I though about the tDeleteFile as a way to solve my problem, but I'm sure you can agree this isn't what I call an elegant design, right ?

I've tried to use tFilterRow too, without success... I'll try to have a look at tJava...

Thanks for the tips anyway !
Four Stars

Re: tAdvancedFileOutputXML creates empty files

Yeah, I understand what you mean. Unfortunately though, sometimes you have to create "band-aids" to make your design work flawlessly, meaning it looks ugly under the hood, but the results are exactly what you need.

I tried a couple of mock-ups of your issue and I cant really find a perfect solution. another idea that came to me is something like

tMap -> tJava -runif -> tOutputFileXML

In the tJava assign a value from the flow to a context parameter, and in the runif check if its null...if it is, it'll stop the flow there...
Community Manager

Re: tAdvancedFileOutputXML creates empty files

Hello
Which version of TOS do you use? I tested it on TOS3.2.3 and it works fine, the job doesn't generate a file if there are not no records.

Best regards

shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re: tAdvancedFileOutputXML creates empty files

The version I use is 3.2.3 r35442.
The clue, to explain this behavior, is that my FileInputXML read several files, and maybe send for each file an "information" to the output components, triggering the creation of a file, even if there is no data ?

My main wish is to merge all the data into a single output file, but when I specify a constant output file name in tAdvancedOutputXML, a new file overrides the previous one. That's why each tAdvancedOuputXML has, as its output file name, a dynamic one, based on a sequence : "MY_PATH" + Numeric.sequence("seq",1,1) + ".xml".

If you can help me to solve this need (merge all the data into a single output file), it will solve my first problem (empty output files).

Please note that I've tried to solve this (merging the output) using tUnite, but as you have seen in another post, I wasn't able to make tUnite work in my job (odd messages about non final variables access error with inner classes...)

I hope I've given you enough information to make this as clear as possible.

Thank you
One Star

Re: tAdvancedFileOutputXML creates empty files

My current workaround to avoid empty files is a PostJob using FileProperties dans DeleteFile based on the size attribute...

Not great, but at least, it works.

I still need a way to :
- merge all the data into single XML files
- or, at least, do not generate empty file (and drop my workarond)

Any clue/idea ?
Six Stars

Re: tAdvancedFileOutputXML creates empty files

Hi,

Will you please check the Advanced settings of component tAdvancedFileOutputXML ?
If it is "Fast with low memory consumption" then change it to "Slow and memory-consuming (Dom4j)"

It should work :-)

Re: tAdvancedFileOutputXML creates empty files

I have an issue with "Create empty element if needed " in tAdvancedoutputfilexml" component. I am creating an xml document by mapping from tXMLmap. I do not want empty elemnts/tags to be created when there is no value in xml. I have uncheck the parameter "Create empty element if needed " in "Advanced setting" of tAdvancedoutputfilexml" component. But still the empty tags getting created. Could you please let me the if there any way I can avoid creating tags when there is no value from mapping?

2019 GARNER MAGIC QUADRANT FOR DATA INTEGRATION TOOL

Talend named a Leader.

Get your copy

OPEN STUDIO FOR DATA INTEGRATION

Kickstart your first data integration and ETL projects.

Download now

What’s New for Talend Summer ’19

Watch the recorded webinar!

Watch Now

Agile Data lakes & Analytics

Accelerate your data lake projects with an agile approach

Watch

Definitive Guide to Data Quality

Create systems and workflow to manage clean data ingestion and data transformation.

Download

Tutorial

Introduction to Talend Open Studio for Data Integration.

Watch