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

Re: Selecting from a node-set using variable path

Subject: Re: Selecting from a node-set using variable path
From: "J.Pietschmann" <j3322ptm@xxxxxxxx>
Date: Tue, 18 Feb 2003 21:30:42 +0100
xsl variables path
gary fong wrote:
This works:
 <xsl:variable name="t1" select="$myNodeSet//a/b/c"/>

This doesn't:
 <xsl:variable name="t2" select="$myNodeSet/$myPath"/>

Ah, this comes up regularly. It's something like doing String a="1 + 1"; int b=1+a; in Java and expecting this is not only doesn't cause the compiler to barf but that b is 3 afterwards.

How do I filter down my node-set based upon some variable
location path?
For simple cases there are pure XPath solutions, however,
in your case you'll have to use an extension function to
invoke a runtime XPath interpreter, for example
 <xsl:variable name="myPath">/a/b/c</xsl:variable>
 <xsl:variable name="t3"
   select="xx:evaluate(concat('$myNodeset/',$myPath))"/>
The inner concat evaluates to the string
 $myNodeset//a/b/c
which in turn is evaluated as XPath expression.

Um, well, IIRC MSXML does not have exactly such an extension
function, but you can use a bit of JScript code to emulate
this. The EXSLT project at sourceforge should have such code.

J.Pietschmann


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.