I am having an issue where the fields I am trying to sum is getting concatenated in XSL. I have tried the solutions given at the following threads but none of them is working for me. The requirement is to create the excel template for Report where the summation field needs to be performed using IF condition i.e. when PEOPLEGROUP is in 'CF1000' or 'CF1100' then output should be the summation of HEADCOUNT field but for some reason the output is displaying side by side rather sum.
Given below is the sample code and the expected value is 508 but it gives me 193315.
Sample data:
<?xml version="1.0" encoding="UTF-8"?>
<DATA_DS>
<G_1>
<PG_BUSINESSUNITNAME>Conventional</PG_BUSINESSUNITNAME>
<G_2>
<PG_DEPARTMENTLEVEL1>Conventional Field</PG_DEPARTMENTLEVEL1>
<G_3>
<PG_DEPARTMENTLEVEL2>Conventional Field Operations - Reporting</PG_DEPARTMENTLEVEL2>
<G_4>
<S_0>0</S_0>
<PG>00001.SVOPR</PG>
<S_5>3.00000001521557E14</S_5>
<PEOPLEGROUP>SVOPR</PEOPLEGROUP>
<HEADCOUNT>3.0</HEADCOUNT>
</G_4>
</G_3>
<G_3>
<PG_DEPARTMENTLEVEL2>Field Operations</PG_DEPARTMENTLEVEL2>
<G_4>
<S_0>0</S_0>
<PG>00001.CF1000</PG>
<S_5>3.00000001521557E14</S_5>
<PEOPLEGROUP>CF1000</PEOPLEGROUP>
<HEADCOUNT>193.0</HEADCOUNT>
</G_4>
<G_4>
<S_0>0</S_0>
<PG>00001.CF1100</PG>
<S_5>3.00000001521557E14</S_5>
<PEOPLEGROUP>CF1100</PEOPLEGROUP>
<HEADCOUNT>315.0</HEADCOUNT>
</G_4>
<G_4>
<S_0>0</S_0>
<PG>00001.CF1200</PG>
<S_5>3.00000001521557E14</S_5>
<PEOPLEGROUP>CF1200</PEOPLEGROUP>
<HEADCOUNT>23.0</HEADCOUNT>
</G_4>
</G_3>
</G_2>
</G_1>
</DATA_DS>
The Sample code is given below
<xsl:for-each select=".//G_4">
<xsl:variable name="ALB" select="'CF1000 CF1100'" />
<xsl:variable name="PGALB" select="PEOPLEGROUP" />
<xsl:if test="contains(concat(' ', $ALB, ' '),concat(' ',$PGALB, ' '))">
<xsl:value-of select="sum(HEADCOUNT)" />
</xsl:if>
</xsl:for-each>
Any help will be appreciated.