• 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
  • Tim Cooke
  • Paul Clapham
  • Devaka Cooray
  • Bear Bibeault
Sheriffs:
  • Junilu Lacar
  • Knute Snortum
  • Liutauras Vilda
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Piet Souris
Bartenders:
  • salvin francis
  • Carey Brown
  • Frits Walraven

What are differences between xsl:variable and xsl:params

 
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
 
Ranch Hand
Posts: 170
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Very similar. Param can have default value.
 
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?
 
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.
 
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
 
The harder you work, the luckier you get. This tiny ad brings luck - just not good luck or bad luck.
Two software engineers solve most of the world's problems in one K&R sized book
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic