Great thanks, as I'm using the EXSLT library elsewhere in the transform
I found the dyn:evaluate() function. The problem now is my XPATH string
contains apostrophes which I can't seem to escape adequately for
dyn:evaluate() to not throw errors.
The string is of the form:
./foo[(_at_)type = 'bar']
I've tried the following XSLT char escaping options expressions:
[One]
<xsl:variable name="testmap" select="dyn:evaluate('./foo[(_at_)type =
'bar']')"/>
Result: Error = "expected ")", found "<name>"
[Two]
<xsl:variable name="testmap" select="dyn:evaluate('./foo[(_at_)type =
'bar']')"/>
Result: Error = "expected ")", found "<name>"
[Three]
<xsl:variable name="testmap" select="dyn:evaluate('./foo[(_at_)type =
\\'bar\\']')"/>
Result: Error = "expected ")", found "<name>"
[Four]
<xsl:variable name="x">'</xsl:variable>
<xsl:variable name="testmap" select="dyn:evaluate(concat('./foo[(_at_)type =
',$x, 'bar',$x,']'))"/>
Result: Parses OK but value is empty.
If I reference this path directly without using evaluate, the correct
node-set is returned. It seems like dyn:evaluate isn't handling embedded
apostrophes but I couldn't Google any workarounds for it.
Matt
Michael Kay wrote:
There's no standard way to construct an XPath expression from a string at
run-time in either XSLT 1.0 or 2.0.
Some products have an extension to do this, for example saxon:evaluate().
If you want a portable solution, the only way around it is to generate a
stylesheet.
Michael Kay
http://www.saxonica.com/
-----Original Message-----
From: Matt Poff [mailto:matt(_dot_)poff(_at_)headfirst(_dot_)co(_dot_)nz]
Sent: 20 August 2007 06:58
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] Evaluate string as XPATH axis in XSLT1.0?
Hi,
I'm trying to resolve a node attribute which contains an
XPATH fragment to actually resolve that path to a value. Is
this possible.
XML with attribute looks like...
<grid-map map="./foo[(_at_)bar]/select" />
XSLT looks like...
<xsl:variable name="path" select="../grid/grid-map[1]/@map"/>
<xsl:value-of select="{$path}" />
Unfortunately, this results in errors... Any ideas?
Thanks in advance,
Matt
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--