Suggesting similar:
For variable $s with string text ...
tokenize($s, '/')[position() = (last()-2 to last())]!replace(.,
'.*\}(.*)\[.*', '$1')=>string-join('/')
On Wed, Aug 17, 2022 at 2:34 PM Martin Honnen martin.honnen@xxxxxx <
xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote:
>
> Am 17.08.2022 um 14:22 schrieb Roger L Costello costello@xxxxxxxxx:
> > Hi Folks,
> >
> > I am using the path() function and it is generating paths like this:
> >
> > /Q{}AeroPublication[1]/Q{}airports[1]/Q{}airport[1]/Q{}icaoCode[1]
> >
> > Now I want to convert that full path into an abbreviated path,
> consisting of just the last 3 names:
> >
> > airports/airport/icaoCode
> >
> > I can write a bunch of XSLT code that does this conversion. But is there
> an XPath expression which does it?
> >
>
> Assuming we process only the result of path() it should be possible with
> tokenize and replace and string-join e.g.
>
>
>
> string-join((('/Q{}AeroPublication[1]/Q{}airports[1]/Q{}airport[1]/Q{}icaoCode[1]'
> => tokenize('/')) ! replace(., '^Q\{[^{]*\}|\[[0-9]+\]$',
> ''))[position() gt last() - 3], '/')
|