xsl-list
[Top] [All Lists]

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

2011-11-03 09:25:39
Hi Andrew, David,

Perfect! Thanks a lot!

Regards,
Manfred

On 03/11/2011, David Carlisle <davidc(_at_)nag(_dot_)co(_dot_)uk> wrote:
<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
powered by MessageLabs.
________________________________________________________________________


--~------------------------------------------------------------------
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>
--~--