Re: [xsl] XPath expression which converts the output of path() into an abbreviated path?

Subject: Re: [xsl] XPath expression which converts the output of path() into an abbreviated path?
From: "Martin Honnen martin.honnen@xxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Thu, 18 Aug 2022 14:08:27 -0000
Am 17.08.2022 um 14:45 schrieb Martin Honnen martin.honnen@xxxxxx:

Am 17.08.2022 um 14:38 schrieb Alan Painter alan.painter@xxxxxxxxx:
Suggesting similar:

For variable $s with string text ...

tokenize($s, '/')[position() = (last()-2 to last())]!replace(.,
'.*\}(.*)\[.*', '$1')=>string-join('/')


Looks way better, I always feel I shoot myself into the foot if I need
to mix ! and => and need a lot of parenthesis but your attempt seemed to
elegantly avoid that problem.


BaseX 10.1 with experimental XQuery 4 (of which XPath 4 is a subset) has been released today with support for the thin arrow operator so that it is easier now to avoid shooting myself into the foot:

tokenize($path, '/')[position() gt last() - 3] ->
replace('^Q\{[^{]*\}|\[[0-9]+\]$', '') => string-join('/')

Current Thread