469,282 Members | 2,301 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,282 developers. It's quick & easy.

Difference between xsl:param and xsl:variable?

Hi!
Can you please explain to me the difference between a xsl:param 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.
Jul 20 '05 #1
3 10850
Karsten Weinert wrote:
Hi!
Can you please explain to me the difference between a xsl:param 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 xsl:param 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">
<xsl:param name="arg" />
...
</xsl:template>

Best regards, Stephan
Jul 20 '05 #2


Karsten Weinert wrote:

Can you please explain to me the difference between a xsl:param 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 <xsl:param> elements you
have in your stylesheet. Check the documentation of your XSLT processor.
And if you have an <xsl:param> 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/

Jul 20 '05 #3
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.
Jul 20 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Xeon | last post: by
1 post views Thread by Tjerk Wolterink | last post: by
10 posts views Thread by Tjerk Wolterink | last post: by
reply views Thread by kirashet | last post: by
2 posts views Thread by sucheta.phatak | last post: by
5 posts views Thread by Afshar Mohebbi | last post: by
reply views Thread by Markchivs | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.