[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Variables in select attributes

Subject: Re: Variables in select attributes
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Mon, 19 Jun 2000 08:16:46 +0100
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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.