Subject: RE: Calculating cumulative values
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Sun, 4 Feb 2007 09:25:11 -0000
|
> You can just use XPath here, no need for recursion:
>
> <xsl:template match="point">
> <xsl:copy>
> <xsl:copy-of select="@*"/>
> <xsl:attribute name="y2">
> <xsl:value-of
> select="sum(./@y1|preceding-sibling::point[@x = current()/@x]/@y1)"/>
> </xsl:attribute>
> </xsl:copy>
> </xsl:template>
>
Though that's O(n^2) - a recursive solution might be O(n).
Michael Kay
http://www.saxonica.com/
|