This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
RE: variable with node in xsl:choose
- From: Jarno dot Elovirta at nokia dot com
- To: <xsl-list at lists dot mulberrytech dot com>
- Date: Tue, 23 Jul 2002 13:27:54 +0300
- Subject: RE: [xsl] variable with node in xsl:choose
- Reply-to: xsl-list at lists dot mulberrytech dot com
Hi,
> first thanks for your helpful reponse to my old question.
> Now my new one:
> I want to use a variable in a for:each... so it works fine:
>
> <xsl:variable name="anzrows" select="//user/nokeyuser/name"/>
> <xsl:for-each select="$anzrows">
>
> But I want the select in the variable choosen by a condition
> like this:
>
> <xsl:choose>
> <xsl:when test="$anznokeyuser > $anzkeyuser"><xsl:variable
> name="anzrows"
> select="//user/nokeyuser/name"/></xsl:when>
> <xsl:otherwise><xsl:variable name="anzrows"
> select="//user/keyuser/name"/></xsl:otherwise>
> </xsl:choose>
>
> I also tried it like this:
>
> <xsl:variable name="anzrows">
> <xsl:choose>
> <xsl:when test="$anznokeyuser >
> $anzkeyuser">//user/nokeyuser/name</xsl:when>
> <xsl:otherwise>//user/keyuser/name</xsl:otherwise>
> </xsl:choose>
> </xsl:variable>
>
> But this doesn't work because he can't convert #RTREEFRAG
> into NodeList.
> Maybe you can help another time :)
I'm not sure how inefficient this is, but
<xsl:variable name="anzrows" select="(//user/nokeyuser/name)[$anznokeyuser > $anzkeyuser]|(//user/keyuser/name)[not($anznokeyuser > $anzkeyuser)]" />
would so it, as would e.g.
<xsl:variable name="anzrows2" select="//user/*[name() = concat(substring('no', 1 + not($anznokeyuser > $anzkeyuser) * 2), 'keyuser')]/name" />
but I'm not sure either one is the best solution for you problem.
Cheers,
Jarno - think I'll stick with this one from now on...
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list