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

  • SEARCH
  • Home
  • 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 6721053
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T09:17:04+00:00 2026-05-26T09:17:04+00:00

So, I know you can’t access variables outside scope, that they’re immutable, that XSLT

  • 0

So, I know you can’t access variables outside scope, that they’re immutable, that XSLT is functional not imperative, etc…

But I need a general purpose approach to something that would be trivial with global mutable variables (that sounds evil just saying it :). Here’s an example…

<xsl:template match="t1">
  <xsl:if test="someLogic">
    <!-- I know, can't do this but just to explain... -->
    <xsl:variable name="varName">numberOrText, maybe even some arithmetic like $varName+1</xsl:variable>
  </xsl:if>
</xsl:template>

<xsl:template match="t2">
  <xsl:value-of select="$varName"/>
</xsl:template>

And the challenge is there could be any number of templates like t1 and t2 at any time during processing and templates that both modify and use the variable.

Maybe part of the problem is that the values depends on the order of processing, but that’s deliberate–that’s what is required.

One possibility I thought of was to pass the values everywhere as parameters. But the problem is that one leaf template might need to change it, and then processing goes back up… it loses that change. Unless there is some way for a template to return parameters and then I could pass those returned parameters on? Thinking of a general purpose pure functional programming language, it seems like that’s how one might do this–calling recursively, but using the return values for further calls so one can “carry forward” the values.

I have seen this done using extensions–calling out to Java methods or something like that and then you can have global mutable values, but… I’d really rather not “cheat” like that.

Any pointers, ideas, etc., welcome.

  • 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-26T09:17:04+00:00Added an answer on May 26, 2026 at 9:17 am

    I think the answer was included in my question and other comments. Here’s quoting some of it:

    “some way for a template to return parameters and then I could pass those returned parameters on? Thinking of a general purpose pure functional programming language, it seems like that’s how one might do this–calling recursively, but using the return values for further calls so one can “carry forward” the values.”

    From user357812: “I think that maybe this can be done with a most fine-grained tree traversal pattern and tunnel param. Only with input and output it’s posible to say exactly how.”

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a query that I know can be done using a subselect, but
may i know can we specify url for http-basic so that only authenticate if
I see that there are two options that I know can be used in
This is something I know can be done somehow , because I've done it
You can know if the event stack is empty calling the gtk.events_pending() method, but
I know I can do most of this by hacking Trac and using Git
I know you can look at the row.count or tables.count, but are there other
I know you can do redirection based on the domain or path to rewrite
I know I can programatically make the taskbar item for a particular window start
I know I can call the GetVersionEx Win32 API function to retrieve the Windows

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.