Subject: Re: Converting a string to node test
From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx>
Date: Sat, 21 Apr 2001 16:04:33 +0100
|
Hi Xavier,
> <!-- This line works -->
> <xsl:copy-of select="$x[@my-attrib-name=$z]/node()"/>
> <!-- This line doesn't, nor any line of that kind I've tried... -->
> <xsl:copy-of select="$x[@$y=$z]/node()"/>
Here, you're trying to evaluate a string (held in the $y variable) as
(part of) an XPath. You can't do that without an extension function
like saxon:evaluate() to do the evaluation.
However, you can compare the name of an attribute to the string. So
you can use the following to find the attribute with the name given by
the $y variable:
@*[local-name() = $y]
And therefore use:
<xsl:copy-of select="$x[@*[local-name() = $y] = $z]/node()" />
I hope that helps,
Jeni
---
Jeni Tennison
http://www.jenitennison.com/
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|