Subject: [xsl] grouping date ranges with associated sums From: dmitrik@xxxxxxxxxxxxxx Date: Mon, 29 Nov 2004 12:13:04 -0500 (GMT-05:00) |
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] Add file name+path to pro, Robert Soesemann | Thread | Re: [xsl] grouping date ranges with, David Carlisle |
Re: [xsl] Preseving character entit, David Carlisle | Date | Re: [xsl] grouping date ranges with, David Carlisle |
Month |