Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to reset the variable value in xsl

 
Christian Nash
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
  • 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?
 
Paul Clapham
Sheriff
Posts: 21107
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • 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
  • 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
Sheriff
Posts: 21107
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
Thanks a lot Paul. Solved the issue.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic