## Re: [xsl] Constructing a sequence: numbers are added up repeatedly

 Subject: Re: [xsl] Constructing a sequence: numbers are added up repeatedly From: David Carlisle Date: Thu, 03 Nov 2011 12:54:29 +0000
```<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
xmlns:f="data:,f"
xmlns:xs="http://www.w3.org/2001/XMLSchema";>```

```<xsl:template name="m">
<xsl:variable name="t1" select="'Mlmlmhmhmvmv'"/>
---
<xsl:sequence select="f:seq(string-to-codepoints(\$t1),0,1)"/>
---
</xsl:template>```

<xsl:function name="f:seq" as="xs:integer*">
<xsl:param name="s" as="xs:integer*"/>
<xsl:param name="t" as="xs:integer"/>
<xsl:param name="p" as="xs:integer"/>
<xsl:variable name="n" select="\$s[1]"/>
<xsl:variable name="m" select="if(\$n=(104,118)) then 0 else if (\$n=122) then -1 else 1"/>
<xsl:sequence select="if(exists(\$s)) then
\$p + \$t,
f:seq(\$s[position()!=1],\$t + \$m, \$p+1) else ()"/>
</xsl:function>
</xsl:stylesheet>

```\$ saxon9 -it m sums.xsl
<?xml version="1.0" encoding="UTF-8"?>
---
1 3 5 7 9 11 12 14 15 17 18 20
---```

David

```________________________________________________________________________
The Numerical Algorithms Group Ltd is a company registered in England
and Wales with company number 1249803. The registered office is:
Wilkinson House, Jordan Hill Road, Oxford OX2 8DR, United Kingdom.```

This e-mail has been scanned for all viruses by Star. The service is