[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
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"!
Created account just so I could give you Kudo. Can't say how many hours I have spent before I stumbled into this solution...
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