Re: [xsl] Calculating cumulative values

Subject: Re: [xsl] Calculating cumulative values
From: "Mukul Gandhi" <gandhi.mukul@xxxxxxxxx>
Date: Sun, 4 Feb 2007 12:17:44 +0530
For sorting, I feel you need to modify Andrew's stylesheet as following:

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

<xsl:output method="xml" indent="yes" />

<xsl:template match="root">
 <xsl:copy>
   <xsl:copy-of select="@*" />
   <xsl:apply-templates select="set">
     <xsl:sort select="@id" data-type="number" />
   </xsl:apply-templates>
 </xsl:copy>
</xsl:template>

<xsl:template match="set">
 <xsl:copy>
   <xsl:copy-of select="@*" />
   <xsl:apply-templates select="point">
     <xsl:sort select="@x" data-type="number" />
     <xsl:sort select="@y1" data-type="number" />
   </xsl:apply-templates>
 </xsl:copy>
</xsl:template>

<xsl:template match="point">
 <xsl:copy>
   <xsl:copy-of select="@*" />
   <xsl:attribute name="y2">
     <xsl:value-of select="sum(preceding-sibling::point[@x =
current()/@x]/@y1 | @y1)" />
   </xsl:attribute>
 </xsl:copy>
</xsl:template>

</xsl:stylesheet>

Although this appears to be the right approach to me (for sorting), I
feel this won't work, because preceding-sibling:: axis reads nodes in
reverse document order (which is static), and does not read nodes from
the sorted sequence (which is what I think you want).


On 2/4/07, Simon Shutter <simon@xxxxxxxxxxx> wrote:
I think I may go with 'conventional' solution provided by Andrew, because it
is natively supported by .Net 2 and my data sets are relatively small and
tranformed pretty quickly.  I will look more into FXSL for the longer term.

If I needed to sort the data before I determined the cumulative numbers, how
do I ensure this happens before aggregating the data?

Thanks,

Simon


--
Regards,
Mukul Gandhi

Current Thread