Reputation: 33
The Below is my input XML:
<?xml version="1.0" encoding="utf-8" ?>
<LogiusInhouse>
<qty9 field="QTY_9,11#">
<type>90</type>
<value>12</value>
</qty9>
<qty9 field="QTY_9,11#">
<type>90</type>
<value>12</value>
</qty9>
<dtm9 field="DTM_9,11#">
<type>145</type>
<date>20130308</date>
<format>102</format>
</dtm9>
</LogiusInhouse>
XSL:
<xsl:template match="/LogiusInhouse">
<xsl:value-of select="abs(sum(qty9[type='90']/value))div 1000 "/>
</xsl:template>
my problem is i need to get the absolute sum afterthat it has to be divided by 1000 but iam not getting the result.Please help me on this.
Upvotes: 3
Views: 3612
Reputation: 5432
Or, you can use just this:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="text" indent="yes"/>
<xsl:template match="/LogiusInhouse">
<xsl:value-of select="sum(qty9/value)" />
</xsl:template>
</xsl:stylesheet>
Upvotes: 2
Reputation: 7173
do not use for-each. use the template below
<xsl:template match="/LogiusInhouse">
<xsl:value-of select="sum(//value)"/>
</xsl:template>
using for-each will output 1212
because for-each node (in your code), the result is 12
Upvotes: 2