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 851355
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T07:25:02+00:00 2026-05-15T07:25:02+00:00

I am not working with XSLT not too long. I read that variable of

  • 0

I am not working with XSLT not too long. I read that variable of XSLT can’t be updated on the fly, so how can i do the following task.

I want to sum up Purchase & Sales and put them into a variable, and make some decision according to these values. (For example, if Purchase is greater then sales then do something if not, do something else)

<rows>
    <row>
        <col attr2="Purchase" >100.00</col>
        <col  attr2="Sales" >100.00</col>
    </row>
    <row >
        <col attr2="Purchase" >19.16</col>
        <col  attr2="Sales" >12.94</col>
    </row>
    <row >
        <col attr2="Purchase" >0.67</col>
        <col  attr2="Sales" >2.74</col>
    </row>
    <row >
        <col attr2="Purchase" >71.95</col>
        <col  attr2="Sales" >61.54</col>
    </row>
    <row >
        <col attr2="Purchase" >3.62</col>
        <col  attr2="Sales" >14.72</col>
    </row>
    <row >
        <col attr2="Purchase">8.80</col>
        <col attr2="Sales">1.22</col>
    </row>
    <row >
        <col attr2="Purchase" >-4.28</col>
        <col  attr2="Sales" >6.53</col>
    </row>
</rows>

if anyone knows, please help me.

  • 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-05-15T07:25:03+00:00Added an answer on May 15, 2026 at 7:25 am

    XSL variables are more constants: once set, their value cannot be changed. The only way of changing a variable is to use a recursive template, and using a named parameter to hold the current sum.

    Or you would, if XSLT didn’t have a sum function!

    <xsl:variable name="$purchase-total" select="sum(col[@attr2='Purchase'])" />
    <xsl:variable name="$sales-total" select="sum(col[@attr2='Sales'])" />
    <xsl:choose>
        <xsl:when test="$purchase-total &gt; $sales-total">
            <!-- Do something -->
        </xsl:when>
        <xsl:otherwise>
            <!-- Do something -->
        </xsl:otherwise>
    </xsl:choose>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Why is the following code (in cocoa) not working? NSString *extension = [fileName pathExtension];
I am trying to debug an ActiveResource call that is not working. What's the
break line tag is not working in firefox, neither in chrome. When i see
Code below is not working as expected to detect if it is in design
InternalsVisibleTo is not working for my managed C++ projects, but it is for my
Session variables are apparently not working for me. I don't know what I'm doing
Help me ..my page index is not working in visual studio. my page load
Recently an application I wrote started not working on Internet Explorer. There has been
I've not gone into much research here, but the intuitive thing is not working:
I don't know if my mind is not working today or if this is

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.