xsl-list
[Top] [All Lists]

Re: [xsl] 0utput Escaping not behaving

2008-02-23 02:47:18


--------------------------------------------------
From: "Marroc" <marrocdanderfluff(_at_)yahoo(_dot_)co(_dot_)in>
Sent: Friday, February 22, 2008 11:02 AM
To: <xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com>
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







--~------------------------------------------------------------------
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>
--~--


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

--~------------------------------------------------------------------
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>
--~--