Link to home
Start Free TrialLog in
Avatar of jmc430
jmc430

asked on

Extract the last word in an element tag XSLT

Greetings!

Is it possible to extract the last word in an element tag?

For example:

<TEXT> This is making me rip my hair out. </TEXT>

Is there a way to just get the last word, "out" out?  

I tried using the following, without success.

<xsl:param name="last" select="($arg/*[position() = last()])"/>

Any advice or guidance is greatly appreciated.

Best regards,
Jamie
Avatar of Gertone (Geert Bormans)
Gertone (Geert Bormans)
Flag of Belgium image

Jamie,

"last" would only work for elements,
not for words seperated by spaces

you need to process the string recursively,
I will post an example in a minute


Cheers!
Avatar of jmc430
jmc430

ASKER

Thanks Geert!!
ASKER CERTIFIED SOLUTION
Avatar of Gertone (Geert Bormans)
Gertone (Geert Bormans)
Flag of Belgium image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Jamie,

in order for the recursive template to work,
I add a normalize-space in the first call to the template
the reason is that otherwise there is a trailing space (possibly)
that breaks the test

in the otherwise, you can call your remove trailing dot template to remove the '.' after the out

cheers

Geert
Avatar of jmc430

ASKER

Thanks so much Geert!  You're totally awesome
Avatar of jmc430

ASKER

:)!
you are welcome