Reputation: 1
I want to initialize a variable inside one for-each block to capture the value stored in the last iteration and use it in the next for-each block with the last value.
<xsl:for-each select="tns:ClientContributionDetails">
<ns1:Line>
<ns1:LineNumber>
<xsl:value-of select="position()*2+1"/>
</ns1:LineNumber>
</ns1:Line>
<ns1:Line>
<ns1:LineNumber>
<xsl:value-of select="(position()+1)*2"/>
</ns1:LineNumber>
</ns1:Line>
</xsl:for-each>
<xsl:for-each select="tns:ThirdPartyContributionDetails">
<ns1:Line>
<ns1:LineNumber>
<!--I want here the loop begins with the value stored in the last iteration of the pervious for-each-->
</ns1:LineNumber>
</xsl:for-each>
Upvotes: 0
Views: 659
Reputation: 117043
initialize a variable inside one for-each block to capture the value stored in the last iteration
The answer becomes trivial once you change the question:
<xsl:variable name="lastLine" select="2*count(tns:ClientContributionDetails) + 2" />
You initialize this after the first for-each block, not inside it.
Upvotes: 1