Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can you pass a string literal with xsl:call-template?

Status
Not open for further replies.

TonyMarston

Programmer
Dec 8, 1999
20
0
0
GB
I have created the following template:

Code:
<xsl:template name=&quot;column_hdg&quot;>
  <xsl:param name=&quot;item&quot;/>
  <xsl:param name=&quot;string&quot;/>

  <!-- create hyperlink to sort on this field -->
  <a><xsl:attribute name=&quot;href&quot;><xsl:value-of select=&quot;$script&quot;/>?orderby=<xsl:value-of select=&quot;name($item)&quot;/>/xsl:attribute>
     <!-- this is supposed to show the value of $string -->
     <xsl:value-of select=&quot;$string&quot;/>
  </a>
  <!-- if sorted by this field insert ascending or descending image -->
  <xsl:if test=&quot;$orderby=name($item)&quot;>
    <img>
      <xsl:attribute name=&quot;src&quot;>order_<xsl:value-of select=&quot;$order&quot;/>.gif</xsl:attribute>
      <xsl:attribute name=&quot;alt&quot;>order_<xsl:value-of select=&quot;$order&quot;/>.gif</xsl:attribute>
    </img>
  </xsl:if>
		
</xsl:template>

I am calling it with the following:

Code:
<xsl:call-template name=&quot;column_hdg&quot;>
   <xsl:with-param name=&quot;item&quot; select=&quot;pers_type_id&quot;/>
   <xsl:with-param name=&quot;string&quot; select=&quot;ID&quot;/>
</xsl:call-template>

Note that $script, $orderby and $order have been declared previously using <xsl:param>

I cannot get this to show the value 'ID' for $string, as 'ID' is not a node, just a literal string. Is there a way I can pass a string that will be treated as a string and not a node?
 
Qualify the string literal as you would in any other situation with single quotes as follows:

<xsl:call-template name=&quot;column_hdg&quot;>
<xsl:with-param name=&quot;item&quot; select=&quot;pers_type_id&quot;/>
<xsl:with-param name=&quot;string&quot; select=&quot;'ID'&quot;/>
</xsl:call-template>
 
Bloody heck, that was simple. Why didn't I think of that?
Problem solved, thank you very much.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top