You can write a recursive named template that extracts the last character of
the string, repeatedly until the last character is a non-digit.
Regards,
Michael Kay
http://www.saxonica.com/
http://twitter.com/michaelhkay
-----Original Message-----
From: Costello, Roger L. [mailto:costello(_at_)mitre(_dot_)org]
Sent: 23 December 2009 14:02
To: 'xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com'
Subject: [xsl] [XSLT 1.0] How to get the last number in a
string of numbers?
Hi Folks,
I have a variable that contains a bunch of numbers:
<xsl:variable name="numbers">
generate some numbers
</xsl:variable>
I want to obtain the last number in $numbers.
For example, this might be the value of $numbers:
6 23 45 67
I want the last number:
67
I want the last number fast, i.e., I want it in constant
time, not O(n), where n is the length of the list of numbers.
Plus, I don't want to use any extension functions/elements.
Finally, I want to use only XSLT 1.0
Can it be done? How?
/Roger
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail:
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--