xsl-list
[Top] [All Lists]

RE: [xsl] Calculating cumulative values

2007-02-04 02:25:50
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[(_at_)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/


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