xsl-list
[Top] [All Lists]

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

2012-12-01 07:48:48
On Sat, Dec 01, 2012 at 11:28:28AM +0100, Martin Honnen scripsit:
Graydon wrote:
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:

<xsl:sequence
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.

Thank you!

I haven't, either, but can burn that bridge on Monday. (and check that
saxon:path() really is faster for the data-set in question than the
above.  I'll be really surprised if it's not.)

-- Graydon

--~------------------------------------------------------------------
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>
--~--