只是我想做简单的加法。当我迭代值时,只是我想要求和并打印该值。XSLT:如何为全局变量赋值
这是我试过的方法。但它只是打印0.
这是我的xml。
<t:Employee>
<t:Earnings_Deductions>
<t:Amount t:PriorValue="">4000</t:Amount>
</t:Earnings_Deductions>
</t:Employee>
<t:Employee>
<t:Earnings_Deductions>
<t:Amount t:PriorValue="">4000</t:Amount>
</t:Earnings_Deductions>
</t:Employee>
<t:Employee>
<t:Earnings_Deductions>
<t:Amount t:PriorValue="">4000</t:Amount>
</t:Earnings_Deductions>
</t:Employee>
我想添加所有金额并显示它像这样。
<item><p>700000</p></item>
<xsl:variable name="Total_Amount" select="0" />
<item>
<xsl:for-each select="//*[local-name() = 'Employee']">
<xsl:for-each select="//*[local-name() = 'Earning_Deductions']"/>
<xsl:variable name="amount"><xsl:value-of select="//*[local-name() = 'Amount']"/></xsl:variable>
<xsl:value-of select="$Total_Amount"><xsl:value-of select="$Total_Amount + $amount"/></xsl:value-of>
</xsl:for-each>
<p><xsl:value-of select="$Total_Amount"></xsl:value-of></p>
</item>
我是新来的xslt。请帮我解决这个问题。
这是XSLT不是如何工作 - 变量不能被更新。显示[完整的输入XML示例,完整的XSLT样式表和您期望的输出](http://stackoverflow.com/help/mcve) - 我确信还有另一种方法。 – 2015-03-08 22:34:44