Reputation: 11
I have the following XML:
<root>
<name>The name</name>
<long>
<path>
<value>Some Value</value>
</path>
</long>
<field>/root/name</field>
<field>/root/long/path/value</field>
</root>
and I want to select these paths in the field tags however, when I try the following:
<xsl:value-of select="/root/field[1]" />
all I get is the text value of the field. Is there a way of selecting the correct node from those values?
Upvotes: 1
Views: 195
Reputation: 5570
If you want the node that contains "/root/node" then your xpath would be:
//*[.='/root/name']
this is called a predicate, where the*
matches any node and the .
is the current node.
Upvotes: 0
Reputation: 243459
Such kind of dynamic evaluation is not supported even in XSLT 2.0.
Maybe the XSLT processor you are using supports EXSLT's dyn:evaluate()
extension function?
Upvotes: 0
Reputation: 57707
You need some form of dynamic evaluation. I believe there is a non-standard function eval()
(or evaluate()
in some implementations) that allows you to use dynamic xpath.
Which XPath processor are you using, and XPath 1.0 or 2.0?
Upvotes: 1