Subject: [xsl] Constructing a sequence: numbers are added up repeatedly From: Manfred Staudinger <manfred.staudinger@xxxxxxxxx> Date: Thu, 3 Nov 2011 13:12:37 +0100 |
Hi, Given <xsl:variable name="t1" select="'Mlmlmhmhmvmv'"/> then <xsl:variable name="t4" select="for $i in 1 to string-length($t1) return if (substring($t1, $i, 1)=('h', 'v')) then 0 else if (substring($t1, $i, 1)='z') then -1 else 1"/> <xsl:variable name="t5" select="for $i in 1 to string-length($t1) return $i + sum(subsequence($t4, 1, $i - 1))"/> gives me what I want in $t5: 1 3 5 7 9 11 12 14 15 17 18 20 While $t4 isn't very efficient, the construct in $t5 is simply unacceptable for longer strings: the numbers are added up repeatedly instead of adding only one number to the previous sum. Any better solution would be appreciated, thanks! Regards, Manfred
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] [possibly off topic] Adop, Andrew Welch | Thread | Re: [xsl] Constructing a sequence: , Andrew Welch |
Re: [xsl] Getting text from string, Stan Mikita | Date | Re: [xsl] Getting text from string, Andrew Welch |
Month |