[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Best way to create a "dictionary"/"map"/"something"

Subject: Best way to create a "dictionary"/"map"/"something"
From: Antonio Fiol <fiol@xxxxxxxxxx>
Date: Tue, 18 Jun 2002 10:19:47 +0200
create a dictionary
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



Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.