Re: [xsl] String concatenation inside open tag

Subject: Re: [xsl] String concatenation inside open tag
From: Martin Honnen <Martin.Honnen@xxxxxx>
Date: Tue, 27 Feb 2007 15:38:00 +0100
Jason Solan wrote:

How my initial thought to handle it is:
If there is a javascript function for this column I would output:
<a href="javascript:void(0)"

I would then add the onclick event for the function name:
onclick="javascript:myFunction(

I think I can handle that part.

The problem comes in because I don't know how to parse the parameters.
I'm in an open "<a" tag so I can't do (unless I'm mistaken) an
xsl:for-each (which is how I would normally handle this situation).

Your stylesheet is a well-formed XML document so you can't never have something like an incomplete tag e.g.
<a href="javascript:void(0)"
in there, instead you would have e.g.
<a href="javascript:void(0)">
and then inside of that you could create further attributes with xsl:attribute e.g.
<xsl:attribute name="onclick">
<xsl:text>myFunction(</xsl:text>
<xsl:for-each select="parameters/param">
<xsl:text>'</xsl:text>
<xsl:value-of select="."/>
<xsl:text>'</xsl:text>
<xsl:if test="position() != last()">
<xsl:text>,</xsl:text>
</xsl:if>
</xsl:for-each>
<xsl:text>); return false;</xsl:text>
</xs:attribute>
Then here you could create further attributes if needed and finally include the contents of the a element
<xsl:text>Bar</xsl:text>
</a>


--

	Martin Honnen
	http://JavaScript.FAQTs.com/

Current Thread