Reputation: 67
I am trying to convert a date received in xs:dateTime format to YYYY/MM/DD input received is : 2002-05-30T09:00:00 Output expected 2002/05/30
Upvotes: 0
Views: 91
Reputation: 52878
You could use a combination of substring-before()
and translate()
...
translate(substring-before(normalize-space(),'T'),'-','/')
Full example...
XML Input
<doc>2002-05-30T09:00:00</doc>
XSLT 1.0
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:template match="doc">
<xsl:copy>
<xsl:value-of select="translate(substring-before(normalize-space(),'T'),'-','/')"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
Output
<doc>2002/05/30</doc>
Fiddle: http://xsltfiddle.liberty-development.net/6rewNxy
Upvotes: 2