Application management : Tools : Enterprise Talk : Examples - data transformation : Data transformation example (Transform datetimes)
Data transformation example (Transform datetimes)
When Talk exports a date time field it is, depending on the type, exported in the following format:
YYYY-MM-DDTHH:mm:SS, for example 2013-11-13T14:12:10
One would like the date to be displayed as DD-MM-YYYY, for example 13-11-2013
You need an export transformation. For more information, also refer to Data transformation example (export).
The original xml file:
<document>
<businessobjects>
<order>
<startDate>2013-11-13T14:12:10</startDate>
</order>
</businessobjects>
</document>
XSLT (xsl file)
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema" version="2.0">
<xsl:template match="/">
<document>
<businessobjects>
<xsl:variable name="bos" select="document/
businessobjects"/>
<xsl:for-each select="document/businessobjects/order">
<order>
<convertedDate>
<xsl:value-of select="format-dateTime
(startDate,'[D]-[M]-[Y]')"/>
</convertedDate>
</order>
</xsl:for-each>
</businessobjects>
</document>
</xsl:template>
</xsl:stylesheet>
Result
<?xml version="1.0" encoding="UTF-8"?>
<document xmlns:xs="http://www.w3.org/2001/XMLSchema">
<businessobjects>
<order>
<convertedDate>13-11-2013</convertedDate>
</order>
</businessobjects>
</document>
For an import one would like to transform from for example 2013-11-13T14:12:10 to 13-11-2013
XSLT (xsl file
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema" version="2.0">
<xsl:template match="/">
<document>
<businessobjects>
<xsl:variable name="bos" select="document
/businessobjects"/>
<xsl:for-each select="document/businessobjects/order">
<order>
<convertedDate>
<xsl:variable name="dt" select="startDate "/>
<xsl:value-of select="concat(substring($dt, 9, 2),
'-',substring($dt, 6, 2),'-',substring($dt, 1, 4),
'T00:00:00')"/>
</convertedDate>
</order>
</xsl:for-each>
</businessobjects>
</document>
</xsl:template>
</xsl:stylesheet>