[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] better way to get the path to a node?

Subject: Re: [xsl] better way to get the path to a node?
From: Martin Honnen <Martin.Honnen@xxxxxx>
Date: Sat, 01 Dec 2012 11:28:28 +0100

Graydon wrote:
Greetings --

If I want to return the XPath path to a specific node when that node is
the context node, is there a better way than:

select="string-join(ancestor-or-self::*/concat('/',name(),'[',for $x in . return count(preceding-sibling::*[name() eq $x/name()])+1,']'),'')"/>

"Better" here means "more efficient"; I'll be using various Saxon 9.*
for this, either in oXygen or from java.

With Saxon there is http://www.saxonica.com/documentation/extensions/functions/path.xml. I haven't checked exactly however for which versions of Saxon 9.* it is available.


	Martin Honnen --- MVP Data Platform Development

Current Thread