• 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
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

Scope of xsl:parameter

 
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
xsl:parameter and xsl:variable?
In one of online tests, I came acorss a question
"what is the scope of the xsl:variable & xsl:param"
I am not clear about the scope.
(Map disabled smiles)
[ July 17, 2002: Message edited by: Mapraputa Is ]
 
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Scope of a variable depends where it is declared.
If it is declared outside of any template then it is a global variable,else if declared inside a template,then it is a local variable and is available only within the template it is declared.
 
Leverager of our synergies
Posts: 10065
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
xsl:variable and xsl:param
Both can be defined inside template, or be a top-level element - i.e. defined as a child of xsl:stylesheet element.
but
xsl:variable is also allowed anywhere within a template where an instruction is allowed, xsl:param not. For example, you can define xsl:variable inside xsl:if element, which wont work for xsl:param.
They have very similar functionality, xsl:param is just another way to implement a variable. The main difference is that xsl:param can get its value from "the calling environment": you specify parameters when calling a stylesheet. For this technique to work, xsl:param must be a child of xsl:stylesheet element, not xsl:template.
Regarding scope, what Vasudha said is true, I would only add that in case of xsl:variable its scope can be even narrower. If it is declared inside some other instruction, like aforementioned xsl:if - then it's scope is this instruction and you cannot access the variable outside of xsl:if construction.
 
Been there. Done that. Went back for more. But this time, I took this tiny ad with me:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic