Subject: Re: [xsl] creating and populating string From: henry human <henry_human@xxxxxxxx> Date: Wed, 10 Jul 2013 14:49:44 +0100 (BST) |
Hi I think the question was representaive enough however it is often the 'human' naure (me too) to give less but get much..... Because the home work was causal I used the xsl:choose for that: <xsl:variable name="buf" select=" concat('0000000000000000000000000', arf:elmentId)"/> <xsl:variable name="systemId" select="arf:elmentId"/> <xsl:choose> <xsl:when test="string-length($systemId) < 25"> <xsl:value-of select="concat(substring($buf, ( (string-length($buf)+1) - 25), string-length($buf)),arf:srvDate)"/> </xsl:when> <xsl:otherwise> <xsl:value-of select="concat(substring(arf:elmentId, string-length(arf:elmentId) - 16), arf:srvDate)"/> </xsl:otherwise> </xsl:choose> Thanks Henry ----- Urspr|ngliche Message ----- Von: Liam R E Quin <liam@xxxxxx> An: xsl-list@xxxxxxxxxxxxxxxxxxxxxx CC: Gesendet: 18:29 Dienstag, 9.Juli 2013 Betreff: Re: [xsl] creating and populating string 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, http://www.w3.org/People/Quin/ Pictures from old books: http://fromoldbooks.org/ Ankh: irc.sorcery.net irc.gnome.org freenode/#xml
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] creating and populating , Liam R E Quin | Thread | [xsl] Using Saxon-CE to implement A, Martynas Jusevičius |
Re: [xsl] Using Saxon-CE to impleme, Michael Kay | Date | [xsl] [Musing] User Preference for , Hank Ratzesberger |
Month |