I had one like this and I came up with:
<xsl:variable name="foo">
<xsl:choose>
<xsl:when test="SOME-TEST">
<xsl:apply-templates select="key('XXX', YYY)" mode="thingy"/>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="ancestor::*[1]" mode="thingy"/>
<xsl:otherwise>
</xsl:choose>
</xsl:variable>
</xsl:template>
<xsl:template select="*" mode="thingy">
process result-tree-fragment here
e.g.
<xsl:copy-of select="*"/>
HTH
john
-----Original Message-----
From: Sameer N [mailto:samooo_vc(_at_)hotmail(_dot_)com]
Sent: 11 June 2004 03:35
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] xsl:variable and key
I want to assign a node-set returned by key() to a variable.
This works fine : <xsl:variable name="foo"
select=3D"key('XXX', YYY)"/>
But now I have a condition and I have to use <xsl:choose>.
And in such case I am not able to set the variable.
The pseudo for what I want is something like this:
<xsl:variable name="foo">
<xsl:choose>
<xsl:when test="SOME-TEST">
SELECT node-set returned by key('XXX', YYY)
</xsl:when>
<xsl:otherwise>
SELECT node-set ancestor::*[1]
<xsl:otherwise>
</xsl:choose>
</xsl:variable>
Any suggesstions? Thanks.
Sameer.
_________________________________________________________________
Is your PC infected? Get a FREE online computer virus scan
from McAfee(r) Security.
http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963
--+------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail:
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--+--
------------------------------------------------------------------------------
Notice: This e-mail message, together with any attachments, contains
information of Merck & Co., Inc. (One Merck Drive, Whitehouse Station, New
Jersey, USA 08889), and/or its affiliates (which may be known outside the
United States as Merck Frosst, Merck Sharp & Dohme or MSD and in Japan, as
Banyu) that may be confidential, proprietary copyrighted and/or legally
privileged. It is intended solely for the use of the individual or entity named
on this message. If you are not the intended recipient, and have received this
message in error, please notify us immediately by reply e-mail and then delete
it from your system.
------------------------------------------------------------------------------