this is the current version of the xsl (each value and sum for the remaining
columns have been removed for
this email):
the exslt reference: exslt="http://exslt.org/common" can be added, but the
question is: where
would your example for the x variable and subsequent node-set be placed so that
all columns and
totals can be displayed? Does the for-next need to be removed from the "x"
variable?
Thanks,
Dmitri
<?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:variable name="global">
<xsl:value-of select="Portfilio/AsOf"/>
</xsl:variable>
<xsl:template match="/">
<html>
<head>
<title>Portfilio</title>
</head>
<body>
<xsl:apply-templates />
</body>
</html>
</xsl:template>
<xsl:template match="Portfilio">
<html>
<style>
td { width: 100px; font-family:verdana; font-size:10px; }
.r0 {background-color: #f0f0f0}
.r1 {background-color: white}
</style>
<body>
<table border=".5">
<tr>
<td >Trade Id</td>
<td align="center">Customer</td>
<td align="center">0</td>
<td align="center">3</td>
<td align="center">6</td>
<td align="center">9</td>
<td align="center">12</td>
<td align="center">15</td>
<td align="center">18</td>
<td align="center">21</td>
<td align="center">24</td>
<td align="center">27</td>
<td align="center">30</td>
</tr>
<xsl:for-each select="Trade">
<tr class="r{position() mod 2}">
<td>
<xsl:value-of select="TradeId"/>: <xsl:text/></td>
<td align="right">
<xsl:value-of select="Customer"/>
</td>
<td align="right">
<xsl:value-of select="format-number(sum(Step
[concat(substring(MinFlowDate,7),substring(MinFlowDate,1,2),substring(MinFlowDate,4,2))>=
concat(substring($global,7),substring($global,1,2),substring($global,4,2))]
[concat(substring(MinFlowDate,7),substring(MinFlowDate,1,2),substring(MinFlowDate,4,2))<
concat(substring($global,7)+3,substring($global,1,2),substring($global,4,2))]
/StepCharge_TTBlack), '###,###,##0')"/>
</td>
</tr>
</xsl:for-each>
<tr>
<td>Totals:
</td>
<td> </td>
<td align="right">
<xsl:text/>
<xsl:value-of select="format-number(sum(Trade/Step
[concat(substring(MinFlowDate,7),substring(MinFlowDate,1,2),substring(MinFlowDate,4,2))>=
concat(substring($global,7),substring($global,1,2),substring($global,4,2))]
[concat(substring(MinFlowDate,7),substring(MinFlowDate,1,2),substring(MinFlowDate,4,2))<
concat(substring($global,7)+3,substring($global,1,2),substring($global,4,2))]
/StepCharge_TTBlack), '###,###,##0')"/>
</td>
</tr>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
-----Original Message-----
From: David Carlisle <davidc(_at_)nag(_dot_)co(_dot_)uk>
Sent: Dec 1, 2004 10:14 AM
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: Re: [xsl] removing comma from within sum command
I
s there a way to remove commas from the Charge node in this select?
Not in pure XSLT 1, no.
in XSLT 1 sum() can only be applied to text that directly occurs in the
source, if you need to do any transformation before summing you have to
go back to your original plan of using a recursive template.
Or simpler (but probably a bit less efficient) if your processor has a
node-set extension first transform the source into a variable removing
commas but not doing a sum, then sum this new node set.
<xsl:variable name="x">
<xsl:for-each select="Trade/Step
[concat(substring(MinFlowDate,7),substring(MinFlowDate,1,2),substring(MinFlowDate,4,2))>=
concat(substring($global,7)+3,substring($global,1,2),substring($global,4,2))]
[concat(substring(MinFlowDate,7),substring(MinFlowDate,1,2),substring(MinFlowDate,4,2))<
concat(substring($global,7)+6,substring($global,1,2),substring($global,4,2))]
/Charge">
<charge><xsl:value-of select="translate(.,',','.')"/></charge>
</xsl:for-each>
</xsl:variable>
</xsl:variable>
<xsl:value-of select="format-number(sum(xx:node-set($x/charge),
'###,###,##0')"/>
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>
--~--
--~------------------------------------------------------------------
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>
--~--