Subject: Re: Variables in select attributes
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Mon, 19 Jun 2000 08:16:46 +0100
|
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
| Current Thread |
- Problems displaying xsl:value-of within quotes, (continued)
- Matthew Cordes - Sat, 17 Jun 2000 13:47:05 -0400
- Robert Koberg - Sat, 17 Jun 2000 12:24:29 -0700
- Mike Brown - Sun, 18 Jun 2000 11:07:02 -0600 (MDT)
- WCB - Sun, 18 Jun 2000 16:17:14 -0700
- Jeni Tennison - Mon, 19 Jun 2000 08:16:46 +0100 <=
- Robert Koberg - Mon, 19 Jun 2000 06:31:20 -0700
- Wendell Piez - Mon, 19 Jun 2000 12:34:32 +0100
- Mike Brown - Mon, 19 Jun 2000 12:09:48 -0600 (MDT)
- Daniel Hinz - Mon, 19 Jun 2000 18:58:35 +0200
|
|