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: "Piez, Wendell A. (Fed) wendell.piez@xxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Thu, 18 Aug 2022 20:36:47 -0000
Hi,

Joel is right: that is a much better approach.

ancestor-or-self::*[position() = (1 to 3)]/local-name(.) => string-join('/')

Unless I am not mistaken this will collect three levels up - while the /
provides for the return sequence to be read top-down (document order) not
bottom up. (Correct?)

Cheers, Wendell


-----Original Message-----
From: Joel Kalvesmaki director@xxxxxxxxxxxxx
<xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Sent: Thursday, August 18, 2022 3:04 PM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Cc: Roger L Costello costello@xxxxxxxxx
<xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Subject: Re: [xsl] XPath expression which converts the output of path() into
an abbreviated path?

Here's another approach, if the XPath expression has icaoCode as the context.
Forget about path(). Just string-join the local names of the ancestors and
self, e.g.,

string-join(for $i in (ancestor-or-self::* except /*) return local-name($i),
'/')

jk

On 2022-08-17 08:22, Roger L Costello costello@xxxxxxxxx wrote:
> 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?
>
> /Roger
>

--
Joel Kalvesmaki
Director, Text Alignment Network
https://gcc02.safelinks.protection.outlook.com/?url=http%3A%2F%2Ftextalign.ne
t%2F&amp;data=05%7C01%7Cwendell.piez%40nist.gov%7C13841fb408ef4d204c1c08da814
c626f%7C2ab5d82fd8fa4797a93e054655c61dec%7C1%7C0%7C637964462324873508%7CUnkno
wn%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6
Mn0%3D%7C3000%7C%7C%7C&amp;sdata=%2Bd9KbarwwwT%2FWrw6Ac57VZ1B5RzupEnOOdzuULy%
2BVoM%3D&amp;reserved=0

Current Thread