Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8293517
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T13:51:14+00:00 2026-06-08T13:51:14+00:00

I would like to increment my global variable tmp_balance_virt in for-each loop but in

  • 0

I would like to increment my global variable tmp_balance_virt in for-each loop but in each loop tmp_balance_virt (a=a+b) is resetting to its initial value, how to make it works?

<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>

EDIT:
That is what works for me.

        <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() &lt; $PREC]/value) + $tmp_balance_real" />
            ],
        </xsl:for-each>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T13:51:16+00:00Added an answer on June 8, 2026 at 1:51 pm

    XSLT is a functional language, which means that variables are immutable. Once set, they can’t be changed. This means you will need to change your approach, and think in a more functional way.

    In this case, you could probably make use of the sum function, and do something like this to initialise the variable

    <xsl:variable 
       name="tmp_balance_virt" 
       select="/doc/plot/@st_balance_virt
         + sum(/doc/plot/cfc/pl.cashflow.rabean.TransactionsData[type=0]/value)" />
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using PHP , I would like to make a while loop that reads a
I would like to increment the ASCII value of several rows of characters. Most
I would like to increment an ip address by a fixed value. Precisely this
I am trying to increment a counter, but I would like to move the
I cant use auto increment in phpmyadmin for this but I would like to
I'm cloning some table rows and would like to increment the IDs of its
I would like to increment two variables in a for -loop condition instead of
I have a double value I would like to increment, using the following snippet:
I have an instance variable in my controller and would like to increment it's
I would like to create an auto increment function that allows me to maintain

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.