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:valu开发者_运维问答e-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?
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?
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?
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.
精彩评论