Link to home
Start Free TrialLog in
Avatar of domaa
domaa

asked on

XSLT manipulating 'action' variable by inserting a '/' (forward slash) only when appending to onclick attribute hor an anchor tag

Hi there,

I am having a peculiar problem using XSLT in .NET v1.

Here is a snippet of the relevant XSLT:
<a>
<xsl:attribute name="href"><xsl:value-of select="./@url"/></xsl:attribute>
<xsl:attribute name="onclick">tvpop('<xsl:value-of select="./@url"/>');return false;</xsl:attribute>
<xsl:attribute name="target">new</xsl:attribute>
<xsl:variable name="sttitle" select="."/>
<xsl:value-of select="ms:rtnTitle(string($stdte),string($sttitle))" disable-output-escaping="yes"/>
</a>

And here is the relevant XML node that the above is transforming:
<title st="10/08/2007 1:20:00 AM" du="30" url="/guide/index.cfm?action=session_info&amp;event_id=18465952">Shopping for Love</title>

Putting these together gives the following HTML:
<a href="http://www.yourtv.com.au/guide/index.cfm?action=session_info&event_id=18465952" onclick="tvpop('http://www.yourtv.com.au/guide/index.cfm?action=/session_info&event_id=18465952');return false;" target="new">Shopping for Love</a>

If you look closely, the first time that the @url attribute is selected, the QS parameter outputs correctly: "action=session_info".  However, in the second select of the @url attribute(where it is used in the onclick event) this same value gets manipulated to 'action=/session_info'.

Why is it doing this?  I have tried output escaping, hard coding the 'action=session_info' part of the url but when the transformation is done, it always puts a '/' before session_info.

Can anybody help?  Is this a bug? Is 'action' some sort of key word?
ASKER CERTIFIED SOLUTION
Avatar of Chirag1211
Chirag1211
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of domaa
domaa

ASKER

Hi Chirag,

I've worked out that the problem is not in fact in the XSLT or XML but the parent control that that is instantiating the transformation.

Corry to bother.
Avatar of domaa

ASKER

Solution not needed