'Convert date format in xslt from YYYYMMDD to MM/DD/YYYY
I am Having date in xml file in format like
YYYYMMDD
Applying the xslt transformation i want to change the format to
MM/DD/YYYY
.
For example, Incoming format - 20160513 Output format - 05/13/2016
Solution 1:[1]
XSLT 2.0 option...
<xsl:template match="date[matches(normalize-space(),'^\d{8}$')]">
<xsl:copy>
<xsl:value-of select="replace(normalize-space(),
'(\d{4})(\d{2})(\d{2})',
'$2/$3/$1')"/>
</xsl:copy>
</xsl:template>
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Daniel Haley |
