Fonctionnalité de Soutien : Enterprise Talk : Exemple de transformation de données (transformer dates-heures) : Exemple de transformation de données (transformer dates-heures)
Exemple de transformation de données (transformer dates-heures)
Lorsque Talk exporte un champ d'heure-date, il est selon le type exporté au format suivant :
YYYY-MM-DDTHH:mm:SS, par exemple 2013-11-13T14:12:10
La date sera affichée comme dd-MM-yyyy, par exemple 13-11-2013
Vous avez besoin d'une transformation d'exportation. Pour de plus amples informations, reportez-vous également à l'exemple de transformation de données (exportation).
Le fichier XML originel :
<document>
<businessobjects>
<order>
<startDate>2013-11-13T14:12:10</startDate>
</order>
</businessobjects>
</document>
XSLT (ficher XSL)
<?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>
Résultat
<?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>
Pour une importation on veut par exemple transformer de 2013-11-13T14:12:10 en 13-11-2013
XSLT (ficher XSL)
<?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>