[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Variables in select attributes
Willy, >I'm trying to do something like this: [snip] > <xsl:variable name="curr_name"> > <xsl:value-of select="name()"/> > </xsl:variable> > <xsl:value-of select="count(//$curr_name)"/> > <xsl:value-of select="$curr_name"/> There is probably a technical explanation waiting to leap forward, but you can think of this as not working because the $curr_name variable holds a string, something like 'foo'. If you imagine substituting that string into the XPath expressions, you get: <xsl:value-of select="count(//'foo')" /> <xsl:value-of select="'foo'" /> Perhaps that makes it clearer why it won't work: the XPath processor isn't expecting a string there. You could instead try: <xsl:value-of select="count(//*[name() = $curr_name])" /> <xsl:value-of select="*[name() = $curr_name]" /> This will give the effect that you're after in this example. There are other alternatives, I believe, in the form of extension functions that evaluate strings as XPath expressions, but I don't know the details of them, nor what XSL processor you're using and whether it has them. I hope that helps anyway, Jeni Dr Jeni Tennison Epistemics Ltd * Strelley Hall * Nottingham * NG8 6PE tel: 0115 906 1301 * fax: 0115 906 1304 * email: jeni.tennison@xxxxxxxxxxxxxxxx XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|