Description
The functx:path-to-node function returns a path to that node, starting with the root element. Specifically, it will concatenate all the names of its ancestors, using a forward slash as a separator.
Note that it is not necessarily a path that will return just that node. For example, if there are several author element children of authors, and you run the function on author, it will return the path authors/author which will return all of the authors, not just the one you ran the function on. See functx:path-to-node-with-pos for a function that returns a unique path to that element.
Arguments and Return Type| Name | Type | Description |
$nodes |
node()* |
the node sequence |
| return value |
xs:string* |
XSLT Function Declaration| See XQuery definition. | <xsl:function name="functx:path-to-node" as="xs:string*"
xmlns:functx="http://www.functx.com">
<xsl:param name="nodes" as="node()*"/>
<xsl:sequence select="
$nodes/string-join(ancestor-or-self::*/name(.), '/')
"/>
</xsl:function>
|
Examples<xsl:variable name="in-xml" as="item()*"> | | <authors>
<author>
<fName>Kate</fName>
<lName>Jones</lName>
</author>
<author>
<fName>John</fName>
<lName>Doe</lName>
</author>
</authors> |
| </xsl:variable> |
| XPath Example | Results |
|---|
functx:path-to-node($in-xml//lName[. = 'Doe']) |
authors/author/lName |
functx:path-to-node($in-xml/*[1]) |
authors/author |
See AlsoHistory |
Recommended Reading: 
|