this is a german Web-Mirror of MHONARC.ORG powered by Domainunion AG

xsl-list
[Top] [All Lists]

Re: [xsl] creating and populating string

2013-07-09 11:29:32
On Tue, 2013-07-09 at 16:03 +0100, henry human wrote:
Hi
I have a string, string1 which could be  1,2,3,..20..100 characters
long
I will only the last 10 characters of the string1 to build string2 and
if string1 shorter than 10 characters string2 should be populated with
'0'

You don't actually ask a question but I'm guessing you want to know how
to use string-length(), substring() and subtraction?

Here's one way to do what I think you are asking for, padding with
leading zeros:

<xsl:variable name="s" select=" concat('0000000000', $input) " />
<xsl:value-of select="substring($s, 1 + string-length($s) - 10, 10)" />

Note, If this is homework, please at least take the time to understand
the solution - maybe use pencil and paper... assuming it does work - I
didn't try it.

Liam

-- 
Liam Quin - XML Activity Lead, W3C, https://www.w3.org/People/Quin/
Pictures from old books: https://fromoldbooks.org/
Ankh: irc.sorcery.net irc.gnome.org freenode/#xml


--~------------------------------------------------------------------
XSL-List info and archive:  https://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: https://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>