Problem with tFileInputXML with empty tag

One Star

Problem with tFileInputXML with empty tag

I have problem with tFileInputXML and empty with data like date or number. I use Java project and TOS Version: V2.1.1 Build id: r4583-20070715-2305.
I have this input file :
<?xml version="1.0" encoding="ISO-8859-15"?>
<SEQ_DATEM>2005-05-01 12:00:00.000</SEQ_DATEM>
Tag SEQ_DATEM is timestamp data.
Tags SEQ_CYCLIQUE, SEQ_DEBUT, SEQ_INC are Long or Integer data
When y try to load the file i have this error :
Exception in component tFileInputXML_1
java.lang.NumberFormatException: For input string: ""
at java.lang.NumberFormatException.forInputString(
at java.lang.Integer.parseInt(
at java.lang.Integer.parseInt(
at routines.system.ParserUtils.parseTo_Integer(
at test.test.Test.tFileInputXML_1Process(
at test.test.Test.main(
Empty tag are consider like empty string not null value Smiley Sad . How can i resolve my problem ?
I join the image of my schema.

One Star

Re: Problem with tFileInputXML with empty tag

The problem could be that the contents of the tags are read as string, if you specify that a certain column is an Integer, TOS will create a class Integer parsing the string.
Of course you can't obtain an Integer class from an empty string.
I think that you can set all the columns as string and after you can work with Integers and Longs using a tMap.
One Star

Re: Problem with tFileInputXML with empty tag

we have just the same problem that you with tFileInputXML component.
We have been looking for a better solution and we have discovered that problem is on code generated.
When tFileInputXML component is looking for the data of a XML node is using XPath (org.dom4j.xpath.DefaultXPath class of dom4j-1.6.1.jar exactly), and when node is not present or value is empty, the "valueOf" method is returning "" (empty String), instead of null value.
This is the default implementation of DOM4J API, so we think that this API is working fine, according to standar.
(If this isn't correct then maybe this API must fix this bug.)
With Talend, in the java source code generated of tFileInputXML component, there is a line to prevent it (null value) but the comparation is only against null value, not empty value.
The line is like: if (str_tFileInputXML_1 != null)
Then the solution is about to do both comparations, prevent it about null value and about empty value, like this:
if (str_tFileInputXML_1 != null && str_tFileInputXML_1.length() > 0)

Therefore, we think that a possible solution is modify the tFileInputXML component:
In tFileInputXML_begin.javajet, line 111, where it's write "if (str_<%=cid %> != null ) { "
replace it with "if (str_<%=cid %> != null && str_<%=cid %>.length() > 0) { "
With this change, the mapping from XML data to Talend/Java types is possible and very easy.
We have made this change and all is working fine, so we think that it's a solution for this presumptive "bug".

NOTE: I suppose that in perl lenguage is possible to do the same, but we can't try it.

One Star

Re: Problem with tFileInputXML with empty tag

Hello again,
we are using the latest stable version:
Talend Version: 2.2.2
Build id: r7074-20071116-2048
Community Manager

Re: Problem with tFileInputXML with empty tag

Hi dmerino
We will consider your suggestion and learn your code.
Thanks for your support!
Best regards

Talend | Data Agility for Modern Business
One Star

Re: Problem with tFileInputXML with empty tag

I think that the best solution is to open a bugtracker for this bug. We have the same problem and it is a big issue in TALEND right now.
There is another case related to this one : Problem when XML tag element is not present in the XML file.
Indeed in XML if a field is not mandatory it can be present or not in the file.
In this case TALEND fill the field with empty string. It is not good the field must be initialised to NULL or better excluded from the schema.
One Star

Re: Problem with tFileInputXML with empty tag

I tried the solution of dmerino but it doesn't work.
Indeed, in the generated java code, no value is assigned to the field if it's null or empty.
So the value is not changed and it?s the previous value (of the previous element)
By exemple, with the file :
The log row result with dmerino solution is :
The lgood og row result is :
For information, we use the java version v2.2.2 r7074.
I did another modification in tFileInputXML to fix the problem.
I opened a bugtracker (where you can see the modified code) :

Re: Problem with tFileInputXML with empty tag

I have added a note in this 2834.


Join us at the Community Lounge.

Register Now


Talend named a Leader.

Get your copy


Kickstart your first data integration and ETL projects.

Download now

What’s New for Talend Summer ’19

Watch the recorded webinar!

Watch Now

Best Practices for Using Context Variables with Talend – Part 4

Pick up some tips and tricks with Context Variables


How Media Organizations Achieved Success with Data Integration

Learn how media organizations have achieved success with Data Integration



Introduction to Talend Open Studio for Data Integration.