I'm trying to re-format a date and it's starting to drive me insane.
I've got the following XML tag:
Code:
<DateOfTravel>2006-08-29T00:00:00</DateOfTravel>
& need to convert it to:
Code:
<DepartureDate>29 August 2006</DepartureDate>
My XSLT currently has the following:
Code:
<xsl:element name="DepartureDate">
<xsl:value-of select="concat(substring(DateOfTravel, 9, 2), ' ')"/>
<xsl:variable name="month" select="substring(DateOfTravel, 6, 2)"></xsl:variable>
<xsl:call-template name="date:month-name">
<xsl:with-param name="month" select="format-number($month, '###')"/>
</xsl:call-template>
<xsl:value-of select="concat(' ', substring(DateOfTravel, 1, 4))"/>
</xsl:element>
.
.
.
.
.
<date:month-names>
<date:month>January</date:month>
<date:month>February</date:month>
<date:month>March</date:month>
<date:month>April</date:month>
<date:month>May</date:month>
<date:month>June</date:month>
<date:month>July</date:month>
<date:month>August</date:month>
<date:month>September</date:month>
<date:month>October</date:month>
<date:month>November</date:month>
<date:month>December</date:month>
</date:month-names>
<xsl:template name="date:month-name">
<xsl:param name="month" select="0"/>
<xsl:value-of select="document('')/*/date:month-names/date:month[$month]"/>
</xsl:template>
I've tried it without the <xsl:variable name="month" select="substring(DateOfTravel, 6, 2)"></xsl:variable> & just using the substring(DateOfTravel, 6, 2) in the with-param, plus I've tried it without the format-number as well - all seem to give me January as the month.
However if I just 'hard-code' a number in the with-param it works OK, which seems to imply that the "date:month-name" template is OK, it's the parameter that isn't, but running it in debug the parameter is '08'
I'm sure it's something straight-forward, help please
as always - thanks in advance