Varun
Varun

Reputation: 526

XSL variable usage

Hi I have one XSL variable

<xsl:variable name="QTime" select="response/lst/int[@name='QTime']"/> 

Now I need to pass this to JavaScript function. Please help me how to do this...

<span onmouseout='c();' onmouseover='s($numFound);'>

For example

<span onmouseout='c();' onmouseover='s(900);'>

Upvotes: 3

Views: 847

Answers (2)

Marc Gravell
Marc Gravell

Reputation: 1062492

Simple:

<span onmouseout='c();' onmouseover='s({$numFound});'>

The { and } are key here - when used in attributes, they are used by xslt as a short-hand to evaluate the contents under xslt rules. This is equivalent to:

<span onmouseout='c();'>
    <xsl:attribute name="onmouseover">s(<xsl:value-of select="$numFound"/>);</xsl:attribute>
</span>

Upvotes: 3

Lukasz
Lukasz

Reputation: 7662

I'm guessing you're generating some HTML with your XSL transformation. Then, you can try this:

<xsl:element name="span">
    <xsl:attribute name="onmouseout">
        <xsl:text>c();</xsl:text>
    </xsl:attribute>
    <xsl:attribute name="onmouseover" select="concat('s(', $numFound, ');')" />
</xsl:element>

Upvotes: 2

Related Questions