Working with quotes in XSLT

I have a XSLT file where I need to pass strings to javascript.   Due to the way the code is written the string designator is the single quote.  Typically that is not an issue but what happens if the text you pass in contains an apostrophe, AKA single quote?  You will need to perform a translation within XSLT to change the apostrophe to "    Now comes the fun part.  Here is a XSLT translation:


<xsl:value-of select=”translate(.,’a’,’A’)” />


so how to you tell XSLT that you want to translate a single quote into the &quot;  After trying various combinations of escapes and multiple single quotes I found that


<xsl:value-of select=”translate(.,&quot;’&quot;,’&quot;’)” />


works.  What a pain!

Leave a Reply

Your email address will not be published. Required fields are marked *


*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>