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:att ribute>
<xsl:attribute name="onclick">tvpop('<xsl :value-of select="./@url"/>');return false;</xsl:attribute>
<xsl:attribute name="target">new</xsl:att ribute>
<xsl:variable name="sttitle" select="."/>
<xsl:value-of select="ms:rtnTitle(string ($stdte),s tring($stt itle))" disable-output-escaping="y es"/>
</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?acti on=session _info& event_id=1 8465952">S hopping 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?
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:att
<xsl:attribute name="onclick">tvpop('<xsl
<xsl:attribute name="target">new</xsl:att
<xsl:variable name="sttitle" select="."/>
<xsl:value-of select="ms:rtnTitle(string
</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?acti
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Solution not needed
ASKER
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.