-1

我编写了一些 xsl 来创建一些 xml 代码,然后对其进行求和。这是代码:

              <xsl:variable name ="tmpTotal">
                <root>
                  <xsl:for-each select="key('idxid',$id)//parent::*/transaction/transaction-date[substring(@iso-date,1,4) = $newyear  ]">
                      <xsl:if test="../transaction-type[@code='E']">
                        <item>
                          <xsl:value-of select="number(../value)"/>
                        </item>
                      </xsl:if>

                    </xsl:for-each>
               </root>
            </xsl:variable>

              <xsl:variable name="value" select="sum(exsl:node-set($tmpTotal)/root/item)" />
              <h3>
                All: <xsl:value-of select="exsl:node-set($tmpTotal)/*"/> <br/>
                Year: <xsl:value-of select="$newyear"/> <br/>
                Value:<xsl:value-of select="$value"/> <br/>

              </h3>

结果如下: 全部:96363464029561 年份:2005 值:73837

数字列表(来自 All: 输出)如下: 9636 3460 29561 总数应为 42657。但是,来自 sum(exsl:node-set($tmpTotal)/root/item) 的总数为 73837。如果xml中的数字是正确的,为什么我得到的总数不正确?在此先感谢您的帮助。

4

1 回答 1

0

你的计算是错误的。9636 + 34640 + 29561 = 73837

于 2012-10-19T17:15:07.613 回答