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

Re: genarate key using a variable

Subject: Re: genarate key using a variable
From: Mukul Gandhi <mukulw3@xxxxxxxxx>
Date: Mon, 1 Sep 2003 01:25:11 -0700 (PDT)
xsl key variable
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:for-each> 
</xsl:if>

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

<!-- 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
xsl:keys

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

Regards,
Mukul

--- 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
> 
> 
> 
> DISCLAIMER:
> 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: 
> http://www.mulberrytech.com/xsl/xsl-list
> 


__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com

 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.