Re: [xsl] Recursion of variable

Subject: Re: [xsl] Recursion of variable
From: David Carlisle <davidc@xxxxxxxxx>
Date: Mon, 15 Aug 2005 22:53:16 +0100
<x>
<r1>
<cnt>8</cnt>
<r2>
<cnt>6</cnt>
<r3>
<cnt>4</cnt>
</r3>
<r3>
<cnt>4</cnt>
</r3>
</r2>
<r2>
<cnt>3</cnt>
</r2>
</r1>
<r1><cnt>2</cnt></r1>
<r1><cnt>2</cnt></r1>
</x>



<xsl:stylesheet version="1.0"
              xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
<xsl:output method = "xml" indent="yes"/>


<xsl:template match="/">
<xsl:apply-templates select="descendant::cnt[1]"/>
</xsl:template>

<xsl:template match="cnt">
<xsl:param name="c" select="1"/>
<o><xsl:value-of select="$c"/>-<xsl:value-of select="$c + ."/></o>

<xsl:apply-templates select="following::cnt[1]">
<xsl:with-param name="c" select="$c + . + 1"/>
</xsl:apply-templates>

</xsl:template>

</xsl:stylesheet>


$ saxon cnt.xml cnt.xsl
<?xml version="1.0" encoding="utf-8"?>
<o>1-9</o>
<o>10-16</o>
<o>17-21</o>
<o>22-26</o>
<o>27-30</o>
<o>31-33</o>
<o>34-36</o>

________________________________________________________________________
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________

Current Thread