nkk1712
asked on
how to sum in xslt
i want use sum function. Here i want perform the sum which in bold,
To help you i have given like this.
[ In this for loop i want sum each xsl:value-of ]
<xsl:template name="getContentiousAmount ">
<xsl:param name="partyReference" as="xs:string"/>
<xsl:for-each select="../../../../../../ facilityPo sition/pos itionInfo/ position[p ositionTyp eCode/uppe r-case(cod e) = 'FACILITYENDOFPERIODCONTEN TIOUSAMOUN T']">
<xsl:chose>
<xsl:when test="../position[position TypeCode/u pper-case( code) eq 'FACILITYENDOFPERIODUNPAID AMOUNT']">
<xsl:value-of select="0"/> </xsl:when>
<xsl:otherwise>
<xsl:value-of select="../../drawdownPosi tion/posit ionInfo/po sition
[positionTypeCode/upper-ca se(code) eq 'DRAWDOWNENDOFPERIODUNPAID AMOUNT'][p artyRefere nce/@href eq $partyReference]
//positionAmounts/node()[n ame() eq 'positionAmount']/amount"/ > </xsl:otherwise>
</xsl:chose>
</xsl:for-each>
</xsl:template>
CPMPROD-D-CPM-LOA-20110617-0000-.XML
To help you i have given like this.
[ In this for loop i want sum each xsl:value-of ]
<xsl:template name="getContentiousAmount
<xsl:param name="partyReference" as="xs:string"/>
<xsl:for-each select="../../../../../../
<xsl:chose>
<xsl:when test="../position[position
<xsl:value-of select="0"/> </xsl:when>
<xsl:otherwise>
<xsl:value-of select="../../drawdownPosi
[positionTypeCode/upper-ca
//positionAmounts/node()[n
</xsl:chose>
</xsl:for-each>
</xsl:template>
CPMPROD-D-CPM-LOA-20110617-0000-.XML
ASKER
please check its a for loop and i want to have sum for the both conditions
Example
the result of the above may give like this....
0
250
350
0
500
now i want the sum as [0 + 250 + 350 + 0 + 500] = 1100.
Acutally its and condition. i am not able to get the proper result when use xpath as
folllows
sum(../../../../../../../f acilityPos ition[posi tionInfo[p osition
[positionTypeCode/upper-ca se(code) eq 'FACILITYENDOFPERIODCONTEN TIOUSAMOUN T'][partyR eference/@ href eq $partyReference]]
[position[positionTypeCode /upper-cas e(code) !='FACILITYENDOFPERIODUNPA IDAMOUNT'] ]]
/drawdownPosition/position Info/posit ion[positi onTypeCode /upper-cas e(code) eq 'DRAWDOWNENDOFPERIODUNPAID AMOUNT']
[partyReference/@href eq $partyReference]//position Amounts/no de()[name( ) eq $elementName]/ag:getPositi onAmount(a mount, currency, $tag_Currency))
Example
the result of the above may give like this....
0
250
350
0
500
now i want the sum as [0 + 250 + 350 + 0 + 500] = 1100.
Acutally its and condition. i am not able to get the proper result when use xpath as
folllows
sum(../../../../../../../f
[positionTypeCode/upper-ca
[position[positionTypeCode
/drawdownPosition/position
[partyReference/@href eq $partyReference]//position
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
the sum() by the way is outside the loop
<xsl:value-of select="sum(../../drawdown
[positionTypeCode/upper-ca
//positionAmounts/node()[n