tags:

views:

153

answers:

3

Hi,

I have A $param that I am passing into a template. I wish to use the value of this parameter as class name for a div. The class is not taking the value of the parameter but taking the parameter name (in the html page it is $param). Is there any way I can use the value of a parameter as a class name?

Thanks

John

+1  A: 

Hi John,
The following should work:

<div>
<xsl:attribute name="class">
<xsl:value-of select="$param"/>
</xsl:attribute>
</div>

Tim

Tim
A: 

Please use the xsl:attribute element to add the value , for example,

print("<div><xsl:attribute name="class"><xsl:value-of select="$param" /></xsl:attribute></div>");
Gripsoft
+4  A: 

To use a XSLT expression in an attribute of a literal result element, surround the expression with braces like so:

<div class="{$param}"> ... </div>

This is known as an attribute value template.

Inshallah