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

Re: Making XPath expressions out of variables

Subject: Re: Making XPath expressions out of variables
From: David Carlisle <davidc@xxxxxxxxx>
Date: Wed, 29 Oct 2003 13:42:53 GMT
variables in xpath expressions
> Is there a way of selecting nodes which have the name $some-variable using an 
> XPath expression?


<xsl:for-each select="//$some-variable">


doesn't work as you can't have a string following //, if some-variable
contains the string 'foo' you can use $some-variable in exactly the
places that you can use 'foo'.

It's strange why this comes up so often, it must be something to do with
the $ syntax, i'm sure that in other programming lists people don't
expect to be able to go

op = "+";
3 op 5;

and get 8.


What you want is

<xsl:for-each select="//*[name()=$some-variable"]>


What you want here
<xsl:if test="$lh-operator $operand $rh-operator">
may be as you suggestan xsl:choose on the possible operators.
Although it depends what you actually want. Actually I can'tt hink of any
postfix operators in XPath so what do you have in mind for $rh-operator
?


Some XSLT engines (eg saxon) have an evaluate extension function that
will evaluate a string as an Xpath expression, which you could also use.


David


-- 
http://www.dcarlisle.demon.co.uk/matthew

________________________________________________________________________
This e-mail has been scanned for all viruses by Star Internet. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________

 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.