Page 1 of 1

How to get the path last element using xslt

Posted: Mon Jul 25, 2022 7:23 pm
by shiney_98
Hi,
I have a param in xslt . For Example, <xsl:param name="filePath"/>

The filepath is something like C:\xml\inwork\bookmap\preview\lessonName
I need to print exactly the lessonName in the attribute value.

I tried using <substring-after($filePath, '/')[last[])"/>
and <substring-after((tokenize($filePath, '/')[last[])"/> , but it is not working

Any possible solutions?

Re: How to get the path last element using xslt

Posted: Tue Jul 26, 2022 9:48 am
by xephon
You have to tokenize the path based on the separator.

Re: How to get the path last element using xslt

Posted: Tue Jul 26, 2022 9:55 am
by Radu
Hi,

Also use the XSLT tokenize function as "substring-after" returns the first occurrence of the match.
Something like:

Code: Select all

<xsl:value-of select="tokenize($filePath, '\\')[last()]"/>
Regards,
Radu

Re: How to get the path last element using xslt

Posted: Tue Jul 26, 2022 7:11 pm
by shiney_98
Thank u Radu