xsl-list
[Top] [All Lists]

Re: [xsl] Calculating cumulative values

2007-02-03 23:48:04
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[(_at_)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(_at_)schemax(_dot_)com> 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

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