How to escape single quotes in XSLT

...well, as much as I have figured out, there is no clean built-in solution for escaping single quotes (') in XSLT. You need this if you e.g. want to generate JavaScript function calls within the generated XML file. So I have found a workaround resp. a not really nice hack to solve this problem as you can see in the following:


<xsl:variable name="apos">'</xsl:variable>
<xsl:value-of select="concat('javaScript_Function_With_String_Parameter (',$apos,.,$apos,')')"/>


In this way you can generate the JavaScript function call "javaScript_Function_With_String_Parameter('currentValue')".

Comments

  1. Anonymous23.3.09

    Helped me a lot.
    Thanx!

    ReplyDelete
  2. Thanks man, this is realy rare solution! And most importent IT WORKS! :)

    ReplyDelete
  3. Great solution, thanks

    ReplyDelete

Post a Comment

Popular posts from this blog

Tuning ext4 for performance with emphasis on SSD usage

NetBeans 6.1: Working with Google´s Android SDK, Groovy and Grails