• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

how to reset the variable value in xsl

 
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I have declared a variable value as
<xsl:variable name="flag">false</xsl:variable>

Now when i call a particular template rule, I want to change the value of this variable to 'true'. How do i do it such that the change reflects globally? How do i then access this variable value?
 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can't change a variable in XSLT. You'll need some other design. Passing parameters comes to mind for your example.
 
Christian Nash
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

How can i implement a global boolean variable functionality in xsl? When the xsl is called the value of this boolean variable is already defined(say false). During some program flow(in some template rule), I want to change the value of this boolean variable to something else(say true). I cannot implement this with xsl:variable and xsl arameter since the values of these cannot change once declared. How do I do this?? any ideas???
 
Paul Clapham
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You need a function that calculates the value of that "variable" in whatever context your code is in. Bear in mind that XSLT is a functional programming language, so time is not a concept. A function will always return the same value for the same inputs.

So you will need to throw away the idea that your variable is true until event X happens and then it's false. You need to find a function that describes your variable in terms of how your input document is and not in terms of how you process the document.

If we had a more detailed description of your problem we might be able to say something more specific.
 
Christian Nash
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks a lot Paul. Solved the issue.
 
Opportunity is missed by most people because it is dressed in overalls and looks like work - Edison. Tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic