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
Web Languages and StandardsXML

Avatar of undefined
Last Comment
Gertone (Geert Bormans)
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

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
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
jmc430

ASKER

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

ASKER

:)!
you are welcome
Web Languages and Standards
Web Languages and Standards

Web development can range from developing the simplest static single page of plain text to the most complex web-based internet applications, electronic businesses, and social network services using a wide variety of languages and standards, including the familiar HTML, JavaScript and jQuery, ASP and ASP.NET, PHP, ColdFusion, CSS, PHP, Flex and Flash, but also the implementation of a broad list of standards including XML, WSDL, SSDL, VoiceXML and many more.

40K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo