Re: [xsl] Dynamic XPath

Subject: Re: [xsl] Dynamic XPath
From: David Carlisle <davidc@xxxxxxxxx>
Date: Fri, 23 May 2003 16:30:14 +0100
> Which then changes the result of   <xsl:variable name="textContent"
> select="{$dynamicPath}/text()" />

but why do you want this (which as you say doesn't work) rather than

<xsl:variable name="textContent"
select="$dynamicPath/text()" />

which does work if you defined it by

	<xsl:variable
name="dynamicPath" select="/document/section/keep/pear"/>

rather than

	<xsl:variable
name="dynamicPath">/document/section/keep/pear</xsl:variable>


Dynamic evaluation is rather expensive, people seem to expect it to be
in XSLT for some reaon, but I doubt many people expect a C compiler to
accept C strings that contain random bits of C expression and somehow
inline the strings into the surrounding expression.


If you really do need to have the strings constructed and evaluated
dynamically (which is not at all clear from your examples)
then the pure xslt way is to generate a stylesheet that uses the
constructed Xpath and execute the new stylesheet.
To avoid that, some systems have an evaluate() extension function in their
extension namespace (saxon does).

David

________________________________________________________________________
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