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

Subject: Re: [xsl] Assembling variable names by XSL and getting them evaluated
From: David Carlisle <davidc@xxxxxxxxx>
Date: Wed, 18 Jan 2006 13:10:40 GMT
> Is there a way to get Saxxon 8B 

ah, so you are using xslt2. It's best to say that up front, the current
version of xslt is 1.0 and you are likely to get a 1.0 answer unless you
specifically ask for 2.0.

>      <td>{$lightsource3}</td>

{} syntax is only used in attribute values, where you can't use an
element. To evaluate an XPath such as {$lightsource3} you'd use
value-of. However you can't construct an xpath on the fly and evaluate
it it (well you can using saxon's evaluate extension) any more than in C
or java or fortran etc, you can't take a string with a bit of language
syntax and evaluate it. You don't have the language parser available at
run time.

You don't want lots of variables just one
<xsl:variable name="key">
<k id="0">unknown</k>
<k id="1">Daylight</k>
.....


Then you just need to use <xsl:value-of
select="$key/k[@id=current()/@exif:Lightsource]"/>

To look up the numbers in your xml fragment.

David

________________________________________________________________________
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________

Current Thread