Subject: [xsl] associated sums gouped by date ranges From: dmitrik@xxxxxxxxxxxxxx Date: Tue, 30 Nov 2004 09:44:19 -0500 (GMT-05:00) |
David, Thank you very much for this response. I've changed the dates from mm/dd/yyyy to dd/mm/yyyy and placed the code inside this template <xsl:template name="addSubtotals"> but it seems to produce the value "0". any ideas what needs to be changed? Thanks, Dmitri > > example from today until 1 year - any MinFlowDate which falls within that > range will be summed assuming you have dd/mm/yyyy then: <xsl:value-of select="sum(Trade/Step [concat(substring(MinFlowDate,7),substring(MinFlowDate,4,2),substring(MinFlowDate,1,2))>= 20041129] [concat(substring(MinFlowDate,7),substring(MinFlowDate,4,2),substring(MinFlowDate,1,2))< 20051129] /StepCharge_TTBlack)"/> does the total, the same without the Trade/ at the beginning would give the sum for each trade separately (if the Trade elements were the current node in that case) David -----Original Message----- From: dmitrik@xxxxxxxxxxxxxx Sent: Nov 29, 2004 12:13 PM To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx Subject: [xsl] grouping date ranges with associated sums the following code produces Trade ED.TEST total:20 ED.TESTFX1 total:7840 what is required to break out the sums into dates ranges, for example from today until 1 year - any MinFlowDate which falls within that range will be summed, and then to be able to specify another date range with an associated sum. tia, dk <?xml version="1.0" encoding="ISO-8859-1"?> <?xml-stylesheet type="text/xsl" href="Ed1.xsl"?> <Portfilio> <Trade> <TradeId>ED.TEST</TradeId> <Step> <MinFlowDate>11/11/2004</MinFlowDate> <StepCharge_TTBlack>10</StepCharge_TTBlack> </Step> <Step> <MinFlowDate>11/11/2005</MinFlowDate> <StepCharge_TTBlack>10</StepCharge_TTBlack> </Step> </Trade> <Trade> <TradeId>ED.TESTFX1</TradeId> <Step> <MinFlowDate>11/11/2004</MinFlowDate> <StepCharge_TTBlack>10</StepCharge_TTBlack> </Step> <Step> <MinFlowDate>11/12/2004</MinFlowDate> <StepCharge_TTBlack>60</StepCharge_TTBlack> </Step> <Step> <MinFlowDate>11/11/2004</MinFlowDate> <StepCharge_TTBlack>1450</StepCharge_TTBlack> </Step> <Step> <MinFlowDate>11/11/2009</MinFlowDate> <StepCharge_TTBlack>6320</StepCharge_TTBlack> </Step> </Trade> </Portfilio> <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output method="html" indent="yes" /> <xsl:template match="/"> <html> <head> <title>Portfilio</title> </head> <body> <h1>Trade</h1> <xsl:apply-templates /> </body> </html> </xsl:template> <xsl:template match="Portfilio"> <table> <tbody> <xsl:apply-templates select="Trade" /> </tbody> </table> </xsl:template> <xsl:template match="Trade"> <tr> <td><xsl:value-of select="TradeId" /></td> <td> <xsl:text>total:</xsl:text> <xsl:call-template name="addSubtotals"> <xsl:with-param name="Steps" select="Step" /> </xsl:call-template> </td> </tr> </xsl:template> <xsl:template name="addSubtotals"> <xsl:param name="Steps" /> <xsl:variable name="Step1" select="$Steps[1]" /> <xsl:variable name="RemainingItems" select="$Steps[position() > 1]" /> <xsl:variable name="subtotal" select="$Step1/StepCharge_TTBlack" /> <xsl:choose> <xsl:when test="$RemainingItems"> <xsl:variable name="subtotals"> <xsl:call-template name="addSubtotals"> <xsl:with-param name="Steps" select="$RemainingItems" /> </xsl:call-template> </xsl:variable> <xsl:value-of select="$subtotal + $subtotals" /> </xsl:when> <xsl:otherwise> <xsl:value-of select="$subtotal" /> </xsl:otherwise> </xsl:choose> </xsl:template> </xsl:stylesheet>
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Can't match node without , David Carlisle | Thread | [xsl] The case of the mysteriously , Wong Chin Shin |
RE: [xsl] skip formatting ala <pre>, Pieter Reint Siegers | Date | RE: [xsl] Can't match node without , Michael Kay |
Month |