Win a copy of Succeeding with AI this week in the Artificial Intelligence and Machine Learning forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
  • Junilu Lacar
Sheriffs:
  • Tim Cooke
  • Jeanne Boyarsky
  • Knute Snortum
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:
  • salvin francis
  • fred rosenberger
  • Frits Walraven

Scope of xsl:parameter

 
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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.
 
My name is Inigo Montoya, you killed my father, prepare to read a tiny ad:
ScroogeXHTML 8.7 - RTF to HTML5 and XHTML converter
https://coderanch.com/t/730700/ScroogeXHTML-RTF-HTML-XHTML-converter
    Bookmark Topic Watch Topic
  • New Topic