Reputation: 11
I am trying to translate the below(Single Quote to Apostrophe):
Input: Toulouse'wer
Output: Toulouse’wer
I tried using the following 2 commands:
<xsl:variable name="apos" select='"'"'/>
<xsl:variable name="rsquo">'</xsl:variable>
translate(text(),$apos,$rsquo)
This command is still giving single quote(') as an output.
<xsl:variable name="apos" select='"'"'/>
<xsl:variable name="rsquo" select='"’"'/>
Here, in this command I am not able to declare the second variable(rsquo) in xslt.
Please Advice.
Upvotes: 1
Views: 1949
Reputation: 116959
You are defining $rsquo
wrong. '
is the apostrophe (same as '
). The code for the right single quotation mark is ’
. So you end up replacing the original apostrophe with itself.
Try it this way:
<xsl:variable name="apos">'</xsl:variable>
<xsl:value-of select="translate(text(), $apos, '’')"/>
Upvotes: 2