[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
At 10:16 AM 11/26/2002, you wrote:
The quickest to write and easiest to use IMO would be to use substring-before() and substring-after() to pick apart the date into pieces you want. For example,
<xsl:template name="my-date">
<xsl:param name="date" value="''"/>
<xsl:if test="$date">
<xsl:variable name="year" select="substring-before($date, '-')" />
<xsl:variable name="month" select="substring-before(
substring-after($date,
'-'),
'-')" />
<xsl:variable name="day" select="substring-before(
substring-after(
substring-after($date,
'-'),
'-'),
'T')" />
<!-- Display date components however you'd like -->
<!-- This one produces MM/DD/YY -->
<xsl:value-of select="$month" />
<xsl:text>/</xsl:text>
<xsl:value-of select="$day" />
<xsl:text>/</xsl:text>
<xsl:value-of select="substring($year, 2)" />
<xsl:if>
</xsl:template>
and call it with something like
I'm sure that there are other examples out there for transforming 12 into 'December' and other niceties.
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Re: [xsl] sort by date
Subject: Re: [xsl] sort by date From: Greg Faron <gfaron@xxxxxxxxxxxxxxxxxx> Date: Tue, 26 Nov 2002 10:36:10 -0700 |
At 10:16 AM 11/26/2002, you wrote:
<a4013 date="1998-01-03T00:00:00">FRUTAS</a4013>
the "T00:00:00" has no use but some one can point an idea to get the desired sort by date?
The quickest to write and easiest to use IMO would be to use substring-before() and substring-after() to pick apart the date into pieces you want. For example,
<xsl:template name="my-date">
<xsl:param name="date" value="''"/>
<xsl:if test="$date">
<xsl:variable name="year" select="substring-before($date, '-')" />
<xsl:variable name="month" select="substring-before(
substring-after($date,
'-'),
'-')" />
<xsl:variable name="day" select="substring-before(
substring-after(
substring-after($date,
'-'),
'-'),
'T')" />
<!-- Display date components however you'd like -->
<!-- This one produces MM/DD/YY -->
<xsl:value-of select="$month" />
<xsl:text>/</xsl:text>
<xsl:value-of select="$day" />
<xsl:text>/</xsl:text>
<xsl:value-of select="substring($year, 2)" />
<xsl:if>
</xsl:template>
and call it with something like
<xsl:call-template name="my-date"> <xsl:with-param name="date" select="/a4013-list/a4013[1]/@date" /> </xsl:call-template>
I'm sure that there are other examples out there for transforming 12 into 'December' and other niceties.
Greg Faron Integre Technical Publishing Co.
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] sort by date, Aniceto Lopez | Thread | Re: [xsl] sort by date, James Fuller |
RE: [xsl] sort by date, Ben Robb | Date | Re: [xsl] sort by date, David Carlisle |
Month |