sherly,
Here is a stylesheet that does what you want
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.o
xmlns:map="urn:internal"
exclude-result-prefixes="m
<xsl:template match="date">
<xsl:call-template name="dateTransformer">
<xsl:with-param name="myDate" select="."/>
</xsl:call-template>
</xsl:template>
<xsl:template name="dateTransformer">
<xsl:param name="myDate"/>
<xsl:variable name="year" select="substring-before($
<xsl:variable name="month" select="substring-before(s
<xsl:variable name="day" select="substring-before(s
<xsl:variable name="time" select="substring(substrin
<xsl:value-of select="$day"/>
<xsl:text> </xsl:text>
<xsl:value-of select="document('')//map:
<xsl:text> </xsl:text>
<xsl:value-of select="$year"/>
<xsl:text>, </xsl:text>
<xsl:value-of select="$time"/>
</xsl:template>
<map:dates>
<map:month id="1">Jan</map:month>
<map:month id="2">Feb</map:month>
<map:month id="3">Mar</map:month>
<map:month id="4">Apr</map:month>
<map:month id="5">May</map:month>
<map:month id="6">Jun</map:month>
<map:month id="7">Jul</map:month>
<map:month id="8">Aug</map:month>
<map:month id="9">Sep</map:month>
<map:month id="01">Jan</map:month>
<map:month id="02">Feb</map:month>
<map:month id="03">Mar</map:month>
<map:month id="04">Apr</map:month>
<map:month id="05">May</map:month>
<map:month id="06">Jun</map:month>
<map:month id="07">Jul</map:month>
<map:month id="08">Aug</map:month>
<map:month id="09">Sep</map:month>
<map:month id="10">Oct</map:month>
<map:month id="11">Nov</map:month>
<map:month id="12">Dec</map:month>
</map:dates>
</xsl:stylesheet>
You need to call the named template, with the date value as argument (with-param)
The only tricky bit is the document('')/...
that is a technique to address elements inside the stylesheet itself,
hence you can use that technique to lookup values in a lookup table
(in the map: namespace)
have fun,
Geert
Main Topics
Browse All Topics





by: GertonePosted on 2006-12-05 at 10:25:50ID: 18078624
Hi sherly,
index.html
first thing to check is exslt
There are anumber of time and date functions that allow formatting
http://www.exslt.org/date/
if your processor does not support the function you require,
you will need some substring processing.
I have some answers posted already on this,
I will look for a pointer.
At the mean time you could checkout EXSLT
Cheers!
Geert