RE: [xsl] how to evaluate a dyna generated variable?

Subject: RE: [xsl] how to evaluate a dyna generated variable?
From: "Michael Kay" <mhk@xxxxxxxxx>
Date: Mon, 8 Sep 2003 10:48:25 +0100
This isn't a good way to tackle this requirement.

exsl:evaluate() does say that all the variables are accessible, but you
might find implementations that aren't conformant with this; it's a
heavy overhead for processor to have to maintain so much context at
run-time.

Better to do it in pure XSLT. Rather than declaring several variables
with semantics hidden in the choice of variable names, use the power of
XML to declare a composite (tree-structured) variable, and access it's
components using path expressions. Unfortunately you will also need the
node-set extension.

<xsl:variable name="participants">
  <p nr="1">Absolute Relation</p>
  <p nr="2">Relative Relation</p>
</xsl:variable>

<xsl:value-of select="xx:node-set($participants)/p[@nr=$type]"/>

Michael Kay


> -----Original Message-----
> From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx 
> [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of Cao Hui
> Sent: 08 September 2003 09:35
> To: XSL-List@xxxxxxxxxxxxxxxxxxxxxx
> Subject: [xsl] how to evaluate a dyna generated variable?
> 
> 
> Hello,
>   I have defined the I18n resources with variables like this: 
> <xsl:variable name="lang.type.participant.1" 
> select="'Absolute Relation'"/> <xsl:variable 
> name="lang.type.participant.2" select="'Relative Relation'"/> 
> <xsl:variable name="lang.type.participant.3" select="'Group 
> Expression'"/>
> 
> and in my stylesheet, I want to get the resource like this: 
> <xsl:value-of 
> select="exsl:evaluate(concat('$lang.type.participant.',Type))">
> but it seems exsl:evaluate only accept variables that contain 
> XPath reference,right? then is there any way to do this?
> 
> Thanks
> Max Cao
> 
> 
> 
> 
> _________________________________________________________
> Do You Yahoo!? 
> 启用电邮帐号,领会雅虎通[身临其境聊电影]的动感魅力,还有网络摄像头+雅
虎通收音机等你来拿
> http://cn.rd.yahoo.com/mail_cn/tag/?http://cn.messenger.yahoo.com
> 
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
> 


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread