我正在尝试翻译以下内容(单引号到撇号):
输入:图卢兹'wer
输出:图卢兹'wer
我尝试使用以下2个命令:
<xsl:variable name="apos" select='"'"'/>
<xsl:variable name="rsquo">'</xsl:variable>
translate(text(),$apos,$rsquo)
该命令仍然给出单引号(')作为输出。
<xsl:variable name="apos" select='"'"'/>
<xsl:variable name="rsquo" select='"’"'/>
在这里,在这个命令中,我不能在xslt中声明第二个变量(rsquo)。
请建议。
您对$rsquo
的定义错误。'
为撇号(与'
相同)。右单引号的代码是’
。所以你最终用它自己替换了原来的撇号。
试试这样:
<xsl:variable name="apos">'</xsl:variable>
<xsl:value-of select="translate(text(), $apos, '’')"/>