90 <...">

Sum function in XSL

Below is my XML input:

<?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 that I need to get the absolute amount after it needs to be divided by 1000, but I do not get the result. Please help me with this.

+3
source share
2 answers

Or you can use only 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>
+2
source

do not use for everyone. use the template below

<xsl:template match="/LogiusInhouse">               
    <xsl:value-of select="sum(//value)"/>                                     
</xsl:template>

using for-each prints 1212out because for each node (in your code) the result12

+2
source

All Articles