[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

associated sums gouped by date ranges

Subject: associated sums gouped by date ranges
From: dmitrik@xxxxxxxxxxxxxx
Date: Tue, 30 Nov 2004 09:44:19 -0500 (GMT-05:00)
gouped
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:  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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.