Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

What are differences between xsl:variable and xsl:params

 
Raymond Law
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What are differences between <xsl:variable> and <xsl aram>?
Please help!
Thank you
RL
 
Tony Yan
Ranch Hand
Posts: 170
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Very similar. Param can have default value.
 
Micheal Jacob
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
How param can have default value ?
I didnt get you. Please explain.
Micheal
 
Tony Yan
Ranch Hand
Posts: 170
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When Params are defined in templates. A default value can be give to each of them. If the template is called without value to a param, that default value is used. If param is defined without value, the default value is "". Varaibles have to be given specific values.
I think Skonnard book chapter 5 talks about it relatively well.
 
Raymond Law
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That means xsl aram value can be changed when template is called, but xsl:variable vlaue cannot be changed since it is static variable.
Please correct me if I'm wrong.
thank you
RL
 
Tony Yan
Ranch Hand
Posts: 170
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I wouldn't think of that way, even though it appears to be that. I think neither param or variable can be changed in value for a given scope, although they can be redefined. To me, changing a value of param or variable means something like this:
<xsl:variable name="vName" select="oldValue"/>
<!-- the following doesn't exist at ALL -->
<xsl:change-variable name="vName" select="newValue"/>
<!-- the above doesn't exist at ALL -->
When you redefine vName in another scope to override the previous one, say, I think it is a new variable. Params are probably the same after all. Templates can have two params in hand when get called, one is the default, when is what get passed. If the passed is not there, then the default is used.
Other opinions?
 
mary morris
Ranch Hand
Posts: 97
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I haven't found any material that helps to me understand the scoope of variables. I have the Skonnard, but am looking for other examples, does anyone know where to look for this.
 
Dan Drillich
Ranch Hand
Posts: 1183
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
http://www.w3.org/TR/xslt#variables says -
The difference is that the value specified on the xsl:param variable is only a default value for the binding; when the template or stylesheet within which the xsl:param element occurs is invoked, parameters may be passed that are used in place of the default values.

Cheers,
Dan
 
Raymond Law
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I understand now! I really appreicate you guys.

Thank you,
RL
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic