Welcome to WebmasterWorld Guest from 54.146.239.96

Forum Moderators: httpwebwitch

Message Too Old, No Replies

Using Function Sum

     

jmorgan1422

5:49 pm on Apr 7, 2010 (gmt 0)

5+ Year Member



I am attempting sum a result based upon an attribute ID with the following stylesheet

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:bpws="http://schemas.xmlsoap.org/ws/2003/03/business-process/" xmlns:acord="http://www.ACORD.org/standards/PC_Surety/ACORD1/xml/"
exclude-result-prefixes="xs"
version="2.0">

<!-- <xsl:variable name="SingleLocation" select="bpws:getVariableData('singleLocation')"/>-->
<xsl:variable name="SingleLocation">
<Location id="L26207" xmlns="http://www.ACORD.org/standards/PC_Surety/ACORD1/xml/" xmlns:p0="http://www.ACORD.org/standards/PC_Surety/ACORD1/xml/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
</xsl:variable>


<xsl:template match="*"><xsl:apply-templates></xsl:apply-templates></xsl:template>

<xsl:template match="acord:WorkCompLineBusiness">
<xsl:variable name="LocationId">
<xsl:value-of select="$SingleLocation/acord:Location/@id"></xsl:value-of>
</xsl:variable>
<xsl:element name="EmployerLocationPayroll">
<xsl:for-each select="//acord:WorkCompRateClass">
<xsl:if test="./@LocationRef = $LocationId">
<xsl:element name="Info">
<xsl:element name="LocationPayroll">
<xsl:value-of select="sum(acord:Exposure)"/>
</xsl:element>
</xsl:element>
</xsl:if>
</xsl:for-each>
</xsl:element>

</xsl:template>

<xsl:template match="text()"/>

</xsl:stylesheet>

Results
<?xml version="1.0" encoding="UTF-8"?><EmployerLocationPayroll><Info><LocationPayroll>20000</LocationPayroll></Info><Info><LocationPayroll>100000</LocationPayroll></Info></EmployerLocationPayroll>

What is the best way to sum(LocationPayroll)? I keep getting the individual values for each based upon the attribute ID and can't get the style sheet to sum the two values.