[resolved] tXMLMap is not working correctly with date fields

One Star

[resolved] tXMLMap is not working correctly with date fields

Hi,
I am working TOS 551 and using xml data. I noticed an issue with xml date fields. See below example:
This simple job reads an xml file, uses the tXMLMap and outputs the data to the log.

Content of tFileInputXML. Nothing special done here. Just reading a testDate.xml file which contains a date field.

In the Map Editor I did an import from File and used my xsd file.
This simple xsd (also attached) contains an type="xs:date" field.
The result is shown below:


As you can see the data is not shown correctly.
Can you please explain what I am doing wrong or if this is a bug, can you please fix?
Looks like Talend is expecting a date always to be in format "dd-mm-yyyy" while the xml dat format is "yyyy-mm-dd".
I'm working around this by changing the date type in the xsd by the String type.
The xml:
<testDate xmlns:xsd="" xmlns:xsi="">
<runDate>2014-09-27</runDate>
</testDate>
The xsd:
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="">
  <xs:element name="testDate">
    <xs:complexType>
      <xs:sequence>
        <xs:element type="xs:date" name="runDate"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>
testDate.zip.zip

Accepted Solutions
Community Manager

Re: [resolved] tXMLMap is not working correctly with date fields

Hi
Click Tree schema editor tab, and then you are able to modify all columns!
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business

All Replies
Community Manager

Re: [resolved] tXMLMap is not working correctly with date fields

Hi 
By default, the date pattern of a Date column is "dd-MM-yyyy", you can change manually it to other format.
Best regards
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re: [resolved] tXMLMap is not working correctly with date fields

Thanks Shong. But I believe that is not possible when reading a date from an xml file.
Please show me where I can change it.
See attached screenshot.
On the top left you'll see the xml tree. I can't change it there. On the bottom left you'll see that the type is document. On the right I can change the output format of the date. If I change that into "yyyy-MM-dd" I just get the result: "0033-03-06" while the input-date was: "2014-09-27"!

regards, Martin
Community Manager

Re: [resolved] tXMLMap is not working correctly with date fields

Hi
Click Tree schema editor tab, and then you are able to modify all columns!
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re: [resolved] tXMLMap is not working correctly with date fields

Shong,
Cool! I totally missed that extra tab.
This indeed solves the issues.
Thanks, Martin
Five Stars

Re: [resolved] tXMLMap is not working correctly with date fields

Created account just so I could give you Kudo. Can't say how many hours I have spent before I stumbled into this solution... Smiley Sad Smiley Sad Smiley Sad I had date in XML file "2018-04-14T09:10:20.88" and the error message was Unparseable Date when I tried to execute Job