xsl-list
[Top] [All Lists]

RE: grouping date ranges with associated sums

2004-11-29 19:43:51
where can this code fit into the below xsl code, so that
one row can be used to display sums within 3 different yearly groups?

<xsl:value-of select="sum(Trade/Step

[concat(substring(MinFlowDate,7),substring(MinFlowDate,4,2),substring(MinFlo
wDate,1,2))&gt;= 20041129]

[concat(substring(MinFlowDate,7),substring(MinFlowDate,4,2),substring(MinFlo
wDate,1,2))&lt;  20051129]
   /StepCharge_TTBlack)"/>


thanks,
dk

<?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>
        <xsl:call-template name="addSubtotals1">
         <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() &gt; 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>

        <br></br>

        <xsl:value-of
select="sum(Trade/Step[concat(substring(MinFlowDate,7),substring(MinFlowDate
,4,2),substring(MinFlowDate,1,2))&gt;=20041129]

[concat(substring(MinFlowDate,7),substring(MinFlowDate,4,2),substring(MinFlo
wDate,1,2))&lt;20051129]/StepCharge_TTBlack)"/>
        <xsl:value-of select="$subtotal + $subtotals" />
<!--
        <xsl:choose>
        <xsl:when test="number($MinFlowDate) >= number($currentdate) and
number($MinFlowDate) &lt;= number($datebucket1)">

        1)<xsl:value-of select="$subtotal + $subtotals" />

        </xsl:when>
        <xsl:when test="number($MinFlowDate) >= number($datebucket1) and
number($MinFlowDate) &lt;= number($datebucket2)">
           2)<xsl:value-of select="$subtotal + $subtotals" />
        </xsl:when>
         <xsl:when test="number($MinFlowDate) >= number($datebucket2) and
number($MinFlowDate) &lt;= number($datebucket3)">
           3)<xsl:value-of select="$subtotal + $subtotals" />
        </xsl:when>
        <xsl:otherwise>
        </xsl:otherwise>
      </xsl:choose> -->




     </xsl:when>
     <xsl:otherwise>
       <xsl:value-of select="$subtotal" />
        <xsl:value-of
select="sum(Trade/Step[concat(substring(MinFlowDate,7),substring(MinFlowDate
,4,2),substring(MinFlowDate,1,2))&gt;=20041129]

[concat(substring(MinFlowDate,7),substring(MinFlowDate,4,2),substring(MinFlo
wDate,1,2))&lt;20051129]/StepCharge_TTBlack)"/>


     </xsl:otherwise>
   </xsl:choose>
</xsl:template>

<xsl:template name="addSubtotals1">
   <xsl:param name="Steps" />
   <xsl:variable name="Step1" select="$Steps[1]" />
   <xsl:variable name="RemainingItems" select="$Steps[position() &gt; 1]" />
   <xsl:variable name="subtotal" select="$Step1/StepCharge_TTBlack" />
   <xsl:choose>
     <xsl:when test="$RemainingItems">
       <xsl:variable name="subtotals">
         <xsl:call-template name="addSubtotals1">
           <xsl:with-param name="Steps" select="$RemainingItems" />
         </xsl:call-template>
       </xsl:variable>
                <xsl:value-of
select="sum(Trade/Step[concat(substring(MinFlowDate,7),substring(MinFlowDate
,4,2),substring(MinFlowDate,1,2))&gt;=20051129]

[concat(substring(MinFlowDate,7),substring(MinFlowDate,4,2),substring(MinFlo
wDate,1,2))&lt;20061129]/StepCharge_TTBlack)"/>


       <!--<xsl:value-of select="$subtotal + $subtotals" />-->
     </xsl:when>
     <xsl:otherwise>
      <!-- <xsl:value-of select="$subtotal" />-->
        <xsl:value-of
select="sum(Trade/Step[concat(substring(MinFlowDate,7),substring(MinFlowDate
,4,2),substring(MinFlowDate,1,2))&gt;=20051129]

[concat(substring(MinFlowDate,7),substring(MinFlowDate,4,2),substring(MinFlo
wDate,1,2))&lt;20061129]/StepCharge_TTBlack)"/>
     </xsl:otherwise>
   </xsl:choose>
</xsl:template>






</xsl:stylesheet>

-----Original Message-----
From: David Carlisle [mailto:davidc(_at_)nag(_dot_)co(_dot_)uk]
Sent: Monday, November 29, 2004 12:26 PM
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: Re: [xsl] grouping date ranges with associated sums



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(MinFlo
wDate,1,2))&gt;= 20041129]

[concat(substring(MinFlowDate,7),substring(MinFlowDate,4,2),substring(MinFlo
wDate,1,2))&lt;  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

________________________________________________________________________
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________

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

---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.802 / Virus Database: 545 - Release Date: 11/26/2004

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.802 / Virus Database: 545 - Release Date: 11/26/2004


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