Re: [xsl] 0utput Escaping not behaving

Subject: Re: [xsl] 0utput Escaping not behaving
From: "Joe Fawcett" <joefawcett@xxxxxxxxxxx>
Date: Sat, 23 Feb 2008 09:46:45 -0000
--------------------------------------------------
From: "Marroc" <marrocdanderfluff@xxxxxxxxxxx>
Sent: Friday, February 22, 2008 11:02 AM
To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
Subject: [xsl] 0utput Escaping not behaving

Hello all,

I have a problem that is possibly a bug. I'm using .NET XslTransform for
XSLT 1.0 (not my choice) to transform XHTML to XHTML.

When I create this element like this:

<xsl:element name="a">
<xsl:attribute name="href">
<xsl:text>javascript:include('</xsl:text>
<xsl:value-of select="@href"/>
<xsl:text>?i=1','</xsl:text>
<xsl:value-of select="@target"/>
<xsl:text>');</xsl:text>
</xsl:attribute>
</xsl:element>

I get this:

<a href="javascript:include('toc41837.htm?i=1','TOC');">

Notice the happy apostrophes. However, when I use a variable $href
containing a query string instead of @href. $href being similar to:

/support?p=Compare&c=Compare/help/6.2/toc41837.htm

I get this:

<a
href="javascript:include(&apos;/support?p=Compare&amp;c=Compare/help/6.2/toc
41837.htm?i=1&apos;,&apos;TOC&apos;);">

I've tried to 'disable-output-escaping' in the xsl:text elements but it
doesn't make any difference. Can anyone say what is going on?

Thanks in advance,
Richard


As an alternative solution how about putting the JavaScript into the a element's onclick attribute? I've found the these suffer less from unwanted escape problems.
Especially, as Michael Kay pointed out, the javascript scheme for href attributes is non-standard anyway.


Joe
http://joe.fawcett.name


Current Thread