Click to See Complete Forum and Search --> : Parameter passing


boscolopes
November 8th, 2003, 10:43 AM
Hi,
I am facing the following problem with XSLT templates.
I would be thankful if somebody could provide the solution.

I have a template::


<xsl:template name="InboxName">
<xsl:param name="p1" select="'Inbox'"/>
< <xsl:value-of select="\$p1"/>
</xsl:template>


Now, If I do

<xsl:call-template name="InboxName">
<xsl:with-param name="p1" select="'Inbox'"/>
</xsl:call-template>


then, "Inbox" is shown properly in the output.
However if I do,


<xsl:call-template name="InboxName">
<xsl:with-param name="p1" select="Inbox"/>
</xsl:call-template>

Then "Inbox" is not shown.
Note that in <xsl:with-param name="p1" select="Inbox"/>,
the single quotes are missing around Inbox
What could cause this error?

Also if i declare a variable "abc" with value "hello" and call the template, the variable's value does not appear in the output.

<xsl:call-template name="InboxName">
<xsl:with-param name="p1" select="$abc"/>
</xsl:call-template>



TIA
--Lincoln

khp
November 8th, 2003, 06:19 PM
The problem is that when you write

<xsl:with-param name="p1" select="Inbox"/>

It will try to evaluate inbox as an xpath expression. If your current node had an element called inbox, then the value of that element would be passed into the p1 element.
It works when you write <xsl:with-param name="p1" select="'Inbox'"/> because 'Inbox' is a string literal, which then evalueates to the string Inbox when evaluated as an xpath.

To pass a string as an parameter you should write


<xsl:with-param name="p1">
<xsl:text>Inbox</xsl:text>
</xsl:with-param>


Or


<xsl:with-param name="p1">
<xsl:value-of select="$abc"/>
</xsl:with-param>

boscolopes
November 12th, 2003, 11:32 PM
Thanks kph!
The information that you have provided was helpful.
bye.