This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Converting a string to node test


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]