Subject: Re: [xsl] XPath expression which converts the output of path() into an abbreviated path? From: "Eliot Kimber eliot.kimber@xxxxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> Date: Thu, 18 Aug 2022 20:46:32 -0000 |
I would probably do: (//info[1]/ancestor-or-self::* => tail()) ! local-name(.) => string-join('/') To get all the but the root element in the path. The => appears to put the ancestor nodes into document order. Cheers, E. _____________________________________________ Eliot Kimber Sr Staff Content Engineer O: 512 554 9368 M: 512 554 9368 servicenow.com<https://www.servicenow.com> LinkedIn<https://www.linkedin.com/company/servicenow> | Twitter<https://twitter.com/servicenow> | YouTube<https://www.youtube.com/user/servicenowinc> | Facebook<https://www.facebook.com/servicenow> From: Piez, Wendell A. (Fed) wendell.piez@xxxxxxxx <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> Date: Thursday, August 18, 2022 at 3:36 PM To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx <xsl-list@xxxxxxxxxxxxxxxxxxxxxx> Subject: Re: [xsl] XPath expression which converts the output of path() into an abbreviated path? [External Email] 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://urldefense.com/v3/__https://gcc02.safelinks.protection.outlook.com/?u rl=http*3A*2F*2Ftextalign.net*2F&data=05*7C01*7Cwendell.piez*40nist.gov*7 C13841fb408ef4d204c1c08da814c626f*7C2ab5d82fd8fa4797a93e054655c61dec*7C1*7C0* 7C637964462324873508*7CUnknown*7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2lu MzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0*3D*7C3000*7C*7C*7C&sdata=*2Bd9KbarwwwT*2F Wrw6Ac57VZ1B5RzupEnOOdzuULy*2BVoM*3D&reserved=0__;JSUlJSUlJSUlJSUlJSUlJSU lJSUlJSU!!N4vogdjhuJM!GpFVFh_0kk-KQPEs12a1rbjJ0jSZeC6psEuHYEssMBDW47_Jygp-iFu s7HTF6YCfnz8UAEnABUSOkbt57T7HNVM9z3ReYdx5qP-JyKWg82k$<https://urldefense.com/ v3/__https:/gcc02.safelinks.protection.outlook.com/?url=http*3A*2F*2Ftextalig n.net*2F&data=05*7C01*7Cwendell.piez*40nist.gov*7C13841fb408ef4d204c1c08d a814c626f*7C2ab5d82fd8fa4797a93e054655c61dec*7C1*7C0*7C637964462324873508*7CU nknown*7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJX VCI6Mn0*3D*7C3000*7C*7C*7C&sdata=*2Bd9KbarwwwT*2FWrw6Ac57VZ1B5RzupEnOOdzu ULy*2BVoM*3D&reserved=0__;JSUlJSUlJSUlJSUlJSUlJSUlJSUlJSU!!N4vogdjhuJM!Gp FVFh_0kk-KQPEs12a1rbjJ0jSZeC6psEuHYEssMBDW47_Jygp-iFus7HTF6YCfnz8UAEnABUSOkbt 57T7HNVM9z3ReYdx5qP-JyKWg82k$>
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] XPath expression which co, Piez, Wendell A. (Fe | Thread | Re: [xsl] XPath expression which co, Norm Tovey-Walsh ndw |
Re: [xsl] XPath expression which co, Piez, Wendell A. (Fe | Date | Re: [xsl] XPath expression which co, Norm Tovey-Walsh ndw |
Month |