RE: [xsl] Dynamic XPath

Subject: RE: [xsl] Dynamic XPath
From: "Philip Fitzsimons" <pfitzsimons@xxxxxxxxxxx>
Date: Fri, 23 May 2003 16:41:43 +0100
My need is because the Xpath are in an XML file - I guess I will have to go
the evaulate or generate a Stylesheet-et :)

In terms of the standard - its would be good to have a function:
	findNode(String path)

thanks

-----Original Message-----
From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx
[mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of David Carlisle
Sent: 23 May 2003 16:30
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: Re: [xsl] Dynamic XPath



> 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


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread