Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > Difference between xsl:param and xsl:variable?

Reply
Thread Tools

Difference between xsl:param and xsl:variable?

 
 
Karsten Weinert
Guest
Posts: n/a
 
      07-04-2004
Hi!
Can you please explain to me the difference between a xslaram and a
xsl:variable? Since I can assign a value to both only once, what's the
point? A small example would help me a lot.

Regards,
Karsten.
--
The email above is not in use. Please write to k dot weinert at gmx
dot net.
 
Reply With Quote
 
 
 
 
Stephan Dahl
Guest
Posts: n/a
 
      07-04-2004
Karsten Weinert wrote:

> Hi!
> Can you please explain to me the difference between a xslaram and a
> xsl:variable? Since I can assign a value to both only once, what's the
> point? A small example would help me a lot.
>
> Regards,
> Karsten.
> --
> The email above is not in use. Please write to k dot weinert at gmx
> dot net.


Hi Karsten,
you can assign different values to xslaram like in the following example

....
<xsl:call-template name="foo">
<xsl:with-param name="arg" select="1"/>
</xsl:call-template>
<xsl:call-template name="foo">
<xsl:with-param name="arg" select="2"/>
</xsl:call-template>
....
<xsl:template name="foo">
<xslaram name="arg" />
...
</xsl:template>

Best regards, Stephan
 
Reply With Quote
 
 
 
 
Martin Honnen
Guest
Posts: n/a
 
      07-04-2004


Karsten Weinert wrote:


> Can you please explain to me the difference between a xslaram and a
> xsl:variable? Since I can assign a value to both only once, what's the
> point? A small example would help me a lot.


An XSLT processor allows (or should allow) you to pass external
parameters to a transformation for the global <xslaram> elements you
have in your stylesheet. Check the documentation of your XSLT processor.
And if you have an <xslaram> element in a named template you can call
that template and pass a parameter in with
<xsl:call-template name="templateName">
<xsl:with-param name="paramName" select="xpathHere" />
</xsl:call-template>
much like in other programming languages you declare a function with
formal parameters and then call it with actual parameters.

A variable is just meant to store some value.

--

Martin Honnen
http://JavaScript.FAQTs.com/

 
Reply With Quote
 
Karsten Weinert
Guest
Posts: n/a
 
      07-05-2004
Thanks, Martin Honnen and Stephan Dahl for the clear explanation. I
can use param to set default values for the stylesheet/named template,
which may or may not be overriden. So param is more powerful than
variable, I could use param instead of variable.

Karsten.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
FAQ 7.17 What's the difference between dynamic and lexical (static) scoping? Between local() and my()? PerlFAQ Server Perl Misc 0 04-15-2011 04:00 AM
FAQ 7.17 What's the difference between dynamic and lexical (static) scoping? Between local() and my()? PerlFAQ Server Perl Misc 0 01-06-2011 05:00 PM
difference between between these "char"s arnuld C++ 33 03-05-2007 03:11 PM
Difference between bin and obj directories and difference between project references and dll references jakk ASP .Net 4 03-22-2005 09:23 PM
Exact difference between 'const char *' and 'char *', also diff between 'const' and 'static' Santa C Programming 1 07-17-2003 02:10 PM



Advertisments