Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New Coder
    Join Date
    Jun 2008
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    XSL,Javascript problem:handling single quotes

    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

  • #2
    Master Coder
    Join Date
    Dec 2007
    Posts
    6,682
    Thanks
    436
    Thanked 890 Times in 879 Posts
    try this:
    Code:
    <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

  • #3
    New Coder
    Join Date
    Jun 2008
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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

  • #4
    New Coder
    Join Date
    Jun 2008
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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 '
    Last edited by vinodh_v_p; 06-13-2008 at 08:33 AM.

  • #5
    New Coder
    Join Date
    Jun 2008
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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

  • #6
    Master Coder
    Join Date
    Dec 2007
    Posts
    6,682
    Thanks
    436
    Thanked 890 Times in 879 Posts
    Quote Originally Posted by vinodh_v_p View Post
    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


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •