[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Best way to create a "dictionary"/"map"/"something"
Hello,
Here is the idea: In french, dates are written as DD MMMM YYYY. So, I have an element with the parameters day, month and year (as numbers, from 1 to whatever) and my named template "from-to" should output something like "du 3 février 2001 au 6 octobre 2002" being "du" and "au" the french words for "from" and "to". So, my template looks like this: <xsl:template name="from-to"> du <xsl:value-of select="/doc/generator/dateform[@prefix='start']/@day" /> <xsl:call-template name="month"> <xsl:with-param name="month" select="/doc/generator/dateform[@prefix='start']/@month" /> </xsl:call-template> <xsl:value-of select="/doc/generator/dateform[@prefix='start']/@year" /> au <xsl:value-of select="/doc/generator/dateform[@prefix='end']/@day" /> <xsl:call-template name="month"> <xsl:with-param name="month" select="/doc/generator/dateform[@prefix='end']/@month" /> </xsl:call-template> <xsl:value-of select="/doc/generator/dateform[@prefix='end']/@year" /> </xsl:template> And here is what I use to map numbers to their corresponding texts. <xsl:template name="month"> <xsl:param name="month" /> <xsl:choose> <xsl:when test="$month=1">janvier</xsl:when> <xsl:when test="$month=2">février</xsl:when> <xsl:when test="$month=3">mars</xsl:when> <xsl:when test="$month=4">avril</xsl:when> <xsl:when test="$month=5">mai</xsl:when> <xsl:when test="$month=6">juin</xsl:when> <xsl:when test="$month=7">juillet</xsl:when> <xsl:when test="$month=8">août</xsl:when> <xsl:when test="$month=9">septembre</xsl:when> <xsl:when test="$month=10">octobre</xsl:when> <xsl:when test="$month=11">novembre</xsl:when> <xsl:when test="$month=12">décembre</xsl:when> </xsl:choose> </xsl:template> Even if this looks as a date formatting problem, it is not. I have other "dictionaries" like the following: <xsl:template name="access-mode"> <xsl:param name="bps"/> <xsl:choose> <xsl:when test="$bps=3600">Modem 28K</xsl:when> <xsl:when test="$bps=4200">Modem 33K</xsl:when> <xsl:when test="$bps=7075">Modem 56K</xsl:when> <xsl:when test="$bps=8000">RNIS 64K</xsl:when> <xsl:when test="$bps=16000">RNIS 128K</xsl:when> <xsl:when test="$bps=32000">ADSL 256K</xsl:when> <xsl:when test="$bps=64000">ADSL 512K</xsl:when> <xsl:when test="$bps=96000">Cable 768K</xsl:when> <xsl:when test="$bps=128000">ADSL 1M</xsl:when> <xsl:when test="$bps=256000">ADSL 2M</xsl:when> </xsl:choose> </xsl:template> Is this the best solution? Is there a better one? N.B. All the options are known when I write the XSL file. Thank you very much. Antonio Fiol XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|