PDA

View Full Version : How to pass an xsl tag as argument


phil
09-05-2002, 01:50 PM
<xsl:template match="analyste">
<p onClick="display('<xsl:value-of select="email"/>')"><xsl:value-of select="nom"/></p>
</xsl:template>

I get the message: The character '<' cannot be used in an attribute value.

I have to pass a string as argument for the function "display()", because if I pass a variable reference (which stores the <xsl:value-of select="email"/>), the argument is set to the last value of the variable.
How can I pass the actual string value of a variable?

Phil

jkd
09-05-2002, 03:01 PM
Instead of <xsl:value-of select="bla"/>, use this:

{bla}

inside the attribute. Alternatively, you could use the <xsl:attribute> tag to set the onclick value.

phil
09-05-2002, 03:27 PM
It doesn't work: < and > are not accepted in an onClick method argument. Strange is that this works:
<xsl:template match="email">
<script language="javascript">
stock("<xsl:value-of select='.' />");
</script>
</xsl:template>
Unfortunately it is useless for want I want to do

Any other idea?

Many thanks

Phil

jkd
09-05-2002, 09:11 PM
{XPathSelector} is for use inside attributes, and returns the value-of of the selector. It *does* work.

If you mean to actually pass just the tag, and not what it evaluates too, you'll need to use &amp;lt and &amp;gt; for < and > (respectively).

phil
09-06-2002, 07:31 AM
I got it by using <xsl:attribute>
Thank you very much

Phil