我想在循环中增加我的全局变量tmp_balance_virt
,for-each
但在每个循环中tmp_balance_virt
(a = a + b)正在重置为其初始值,如何使其工作?
<xsl:variable name="tmp_balance_virt" select="/doc/plot/@st_balance_virt" /> //first value
...
<xsl:if ...>
...
<xsl:for-each
select="/doc/plot/cfc/pl.cashflow.rabean.TransactionsData[type=0]">
<xsl:variable name="tmp_balance_virt" select="value + $tmp_balance_virt" />
[
<xsl:value-of select="date_ms" />
,
<xsl:value-of select="$tmp_balance_virt" />
],
</xsl:for-each>
编辑:这对我有用。
<xsl:for-each
select="/doc/plot/cfc/pl.cashflow.rabean.TransactionsData[type=1]">
<xsl:variable name="PREC"
select="count(preceding-sibling::pl.cashflow.rabean.TransactionsData[type=1])+2" />
[
<xsl:value-of select="date_ms" />
,
<xsl:value-of
select="sum(/doc/plot/cfc/pl.cashflow.rabean.TransactionsData[type=1][position() < $PREC]/value) + $tmp_balance_real" />
],
</xsl:for-each>