xsl-list
[Top] [All Lists]

Re: [xsl] &

2007-03-21 04:35:21
Marco wrote:

<A onmouseout="cs()" href="{./@url}"><xsl:attribute name="onmouseover"><xsl:text>return ss('visit </xsl:text><xsl:value-of select="./@visible_url" disable-output-escaping="yes" /><xsl:text>')</xsl:text></xsl:attribute>TITLE</A><br />
<font size="-1"><span class="test">BODY</span><br />
<a HREF="{./@url}"><font size="-1"><xsl:value-of select="./@visible_url" disable-output-escaping="yes"/></font></a>
</font>


the problem is the onmouseover attribute where I get:

url2?escape&amp;amp;chars and in my page I see url2?escape&amp;chars


You are making it much harder than you need to. Do not use onmouseover just to display a text, use the attribute 'title', which works on all modern browsers and does the escaping automatically.

Further, you are mixing your problem a bit, it is not XSLT, but js scripting that contains your problem. You show us your HTML (one advice: please use only lower-case for attribute and element names in HTML, that way you are prepared for XHTML) from within XSLT, but what we need is the output from the processor.

The problem is not in your disable-output-escaping, but in the way that browser escape, render and display your data. What is inside the <a>...</a> is automatically resolved, hence any &amp; will become &. But what's in your javascript depends on how you deal with it. I'm not sure of the JS function, but I guess you want something like value.unescape(). But then again, this can likely be achieved with a simple title attribute.

Furthermore, if you do stick to the onmouseover with a javascript call, using the same text as already in the a-href element, use the popular (but often discouraged) syntax of your_function(this), which gives you all control you need. You will see that if you use, in your script, obj.href or obj.firstChild.value that you will still see the unescaped value of your @visible url.

Last but not least: you do not need to prefix your XPath expressions with ' ./ ', you can safely remove that. But of course, that's all a matter of taste.

Cheers,
-- Abel Braaksma
  http://www.nuntia.nl

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>