M
Mark
Hello,
I'm having problems with an XSLT template I'm developing.
I have a date in an odd format which I'm trying to convert into something
more readable. The original date is in the format YYYY-MM-DD, and I'd like
to convert it to DD MON YY.
I pass the date into my template thusly in my XSLT stylesheet (date-updated
is the data I'm passing in):
<xsl:call-template name="formatDate">
<xsl:with-param name="string" select="date-updated" />
</xsl:call-template>
.... and the template is thus:
<xsl:template name="formatDate">
<xslaram name="inDate" />
<!-- Day -->
<xsl:variable name="day" select="number(substring($inDate, 9, 2))" />
<!-- Month -->
<xsl:variable name="month" select="number(substring($inDate, 6, 2))" />
<xsl:variable name="converted-month">
<xsl:choose>
<xsl:when test="$month=format-number('01', '00')">
<xsl:value-of select="Jan" />
</xsl:when>
....
<xsl:when test="$month='12'">
<xsl:value-of select="Dec" />
</xsl:when>
</xsl:choose>
</xsl:variable>
<!-- Year -->
<xsl:variable name="year" select="number(substring($inDate, 3, 2))" />
<!-- Formatted Date -->
<xsl:value-of select="concat($inDate, ': ', format-number($day, '00'), '
', $converted-month, ' ', format-number($year, '00'))" />
</xsl:template>
The output I get is:
: NaN NaN
NaN = Not a number, of course, but I can't see why such an error should be
raised.
Thanks for any assistance,
Mark
I'm having problems with an XSLT template I'm developing.
I have a date in an odd format which I'm trying to convert into something
more readable. The original date is in the format YYYY-MM-DD, and I'd like
to convert it to DD MON YY.
I pass the date into my template thusly in my XSLT stylesheet (date-updated
is the data I'm passing in):
<xsl:call-template name="formatDate">
<xsl:with-param name="string" select="date-updated" />
</xsl:call-template>
.... and the template is thus:
<xsl:template name="formatDate">
<xslaram name="inDate" />
<!-- Day -->
<xsl:variable name="day" select="number(substring($inDate, 9, 2))" />
<!-- Month -->
<xsl:variable name="month" select="number(substring($inDate, 6, 2))" />
<xsl:variable name="converted-month">
<xsl:choose>
<xsl:when test="$month=format-number('01', '00')">
<xsl:value-of select="Jan" />
</xsl:when>
....
<xsl:when test="$month='12'">
<xsl:value-of select="Dec" />
</xsl:when>
</xsl:choose>
</xsl:variable>
<!-- Year -->
<xsl:variable name="year" select="number(substring($inDate, 3, 2))" />
<!-- Formatted Date -->
<xsl:value-of select="concat($inDate, ': ', format-number($day, '00'), '
', $converted-month, ' ', format-number($year, '00'))" />
</xsl:template>
The output I get is:
: NaN NaN
NaN = Not a number, of course, but I can't see why such an error should be
raised.
Thanks for any assistance,
Mark