Re: [xsl] genarate key using a variable

Subject: Re: [xsl] genarate key using a variable
From: Mukul Gandhi <mukulw3@xxxxxxxxx>
Date: Mon, 1 Sep 2003 01:25:11 -0700 (PDT)
With XSLT 1.0 you cannot keep 'match' and 'use'
attributes of xsl:key as variables. I can suggest a
workaround though ;)

You can have two variables lets say var1 and var2
passed as parameters to stylesheet. These variables
will identify *which key you must use* in the XSLT.

for e.g. the XSLT will be like --
<xsl:param name="var1"/>
<xsl:param name="var2"/>

<xsl:key name="x" match="something" use="@Deposit"/>
<xsl:key name="y" match="something" use="@Something"/>

<xsl:if test="$var1 = 1">
  <xsl:for-each select="key('x',$var2)">
    <!-- do some processing -->

<xsl:if test="$var1 = 2">
  <xsl:for-each select="key('y',$var2)">
    <!-- do some processing -->

<!-- more ifs if required .. -->

In this way you are able to parameterize the
processing. The workaround is --
1. Define multiple xsl:keys in the XLST
2. Pass the paremeters to XSLT to use one of the

In the above example -- var1 will select which key to
use(x or y), and var2 will provide value for @Deposit
or @Something .. You can define as many keys as you
want x, y, z, u, .. etc


--- aruniima.chakrabarti@xxxxxxxxxxxxxxxxxx wrote:
> Hi All,
> Is it possible to generate a xsl:key using a
> variable ? 
> As in  xsl:key element it does not allow me to use a
> variable in either match or use attribute. So is
> there any other way to do the same...
> 	e.g. 
> 		I want to search for all Rows with attribute say
> "@Deposit = 1"  
> 		where I receive both the attribute & the attribute
> value as parameters from the user.
> Regards,
> aruniima
> This message contains privileged and confidential
> information and is intended only for the individual
> named.If you are not the intended recipient you
> should not disseminate,distribute,store,print, copy
> or deliver this message.Please notify the sender
> immediately by e-mail if you have received this
> e-mail by mistake and delete this e-mail from your
> system.E-mail transmission cannot be guaranteed to
> be secure or error-free as information could be
> intercepted,corrupted,lost,destroyed,arrive late or
> incomplete or contain viruses.The sender therefore
> does not accept liability for any errors or
> omissions in the contents of this message which
> arise as a result of e-mail transmission. If
> verification is required please request a hard-copy
> version.
>  XSL-List info and archive: 

Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software

 XSL-List info and archive:

Current Thread