[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

RE: [xsl] Assembling variable names by XSL and getting them evaluated


Subject: RE: [xsl] Assembling variable names by XSL and getting them evaluated
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Wed, 18 Jan 2006 14:11:09 -0000

Use a lookup table:

<xsl:variable name="lookup">
  <a code="0">unknown</a>
  <a code="1">Daylight</a>
</xsl:variable>

<xsl:value-of select="$lookup/a[code=$code]"/>

Michael Kay
http://www.saxonica.com/


> -----Original Message-----
> From: cavecatem@xxxxxxxxxxxxx [mailto:cavecatem@xxxxxxxxxxxxx]
> Sent: 18 January 2006 13:51
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: [xsl] Assembling variable names by XSL and getting
> them evaluated
>
>
> Hi all,
>
> now to my second problem. In XMP, a lot of data are shown as
> numbers that stand for certain strings, e.g. exif:LightSource
> (integer)
> 0 = unknown
> 1 = Daylight
> 2 = Fluorescent
> 3 = Tungsten
> 4 = Flash
> 9 = Fine weather
> 10 = Cloudy weather
> 11 = Shade
> 12 = Daylight fluorescent
> (D 5700  7100K)
> 13 = Day white fluorescent
> (N 4600  5400K)
> 14 = Cool white fluorescent
> (W 3900  4500K)
> 15 = White fluorescent
> (WW 3200  3700K)
> 17 = Standard light A
> 18 = Standard light B
> 19 = Standard light C
> 20 = D55
> 21 = D65
> 22 = D75
> 23 = D50
> 24 = ISO studio tungsten
> 255 = other
>
>
> For display, I naturally need the strings and not the numbers.
>
> So I though I'd declade them all as variables
>
> ...
>
> <xsl:variable name="lightsource18"><xsl:text> Standard light
> B</xsl:text></xsl:variable>
>     <xsl:variable name="lightsource19"><xsl:text> Standard
> light C</xsl:text></xsl:variable>
>     <xsl:variable name="lightsource20"><xsl:text>
> D55</xsl:text></xsl:variable>
>     <xsl:variable name="lightsource21"><xsl:text>
> D65</xsl:text></xsl:variable>
>     <xsl:variable name="lightsource22"><xsl:text>
> D75</xsl:text></xsl:variable>
>     <xsl:variable name="lightsource23"><xsl:text>
> D50</xsl:text></xsl:variable>
>     ...
>
>
>     and them call them in the template
>
>     <td>Lichtquelle</td>
>                             <td>
>                                {$lightsource<xsl:value-of
> select="@exif:Lightsource"/>}
>      </td>
>
> thus creating the required variable name on the fly.
>      But unfortunately, the result is
>
>      <td>Lichtquelle>/td>
>      <td>{$lightsource3}</td>
>
>      but the variable is not evaluated. Is there a way to get
> Saxxon 8B to do this?
>      Or am I totally onthe wrong track here?
>
>
>      Thanks for any help
>
>      Regards
>      CJ


Current Thread
Keywords
xsl