...

View Full Version : XSL,Javascript problem:handling single quotes



vinodh_v_p
06-12-2008, 01:33 PM
Hi,
I am having an xsl file in which I am trying to pass a value from an xsl variable to an HTML td named "descID" using javascript.
The following is the code fragment for this.
<xsl:if test="not($descriptionVal='null')">
<script>
document.getElementById("descID").innerHTML='<xsl:value-of select="normalize-space($descriptionVal)" disable-output-escaping="yes"/>';
</script>
</xsl:if>
The problem is that when descriptionVal contains single quotes , I am getting a javascript error.I tried to convert single quotes to &#39; .But no use.

Can anybody give me some idea ,how to handle this situation?
Please help..

Thanks

oesxyl
06-13-2008, 03:20 AM
try this:


<xsl:if test="not($descriptionVal='null')">
<script><![CDATA[
document.getElementById("descID").innerHTML='<xsl:value-of select="normalize-space($descriptionVal)" disable-output-escaping="yes"/>';
]]></script>
</xsl:if>

another way is to replace ",',<,> and & with entities, &quot;, &apos;, &lt;, &gt; and &amp;

regards

vinodh_v_p
06-13-2008, 07:28 AM
Hi,

Thanks for the reply.
Anyway I got a solution to this problem.
I replaced all occurances of ' with ’ using "translate" method.
And it is working now.

Thanks
Vinodh

vinodh_v_p
06-13-2008, 07:30 AM
Sorry I think what I meant is not coming properly.
I replaced all single quotes with #8217; (prefix an & with this value).
But still what I am getting is a right single quote.Is ther a way to replace '

vinodh_v_p
06-13-2008, 08:21 AM
I am still facing one problem.In one server I am getting the single quotes for #8217;.
But in another server I am getting question mark for this value.
Can anybody give me a solution to this problem.?

Thanks

oesxyl
06-13-2008, 11:14 AM
I am still facing one problem.In one server I am getting the single quotes for #8217;.
But in another server I am getting question mark for this value.
Can anybody give me a solution to this problem.?

Thanks
did you try what I said in my replay?

regards



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum