如何在XsLT中将单引号转换为撇号(卷曲引号)



我正在尝试翻译以下内容(单引号到撇号):

输入:图卢兹'wer

输出:图卢兹'wer

我尝试使用以下2个命令:

<xsl:variable name="apos" select='"&apos;"'/> <xsl:variable name="rsquo">&#39;</xsl:variable> translate(text(),$apos,$rsquo)

该命令仍然给出单引号(')作为输出。

<xsl:variable name="apos" select='"&apos;"'/> <xsl:variable name="rsquo" select='"&rsquo;"'/>

在这里,在这个命令中,我不能在xslt中声明第二个变量(rsquo)。

请建议。

您对$rsquo的定义错误。&#39;为撇号(与&apos;相同)。右单引号的代码是&#8217;。所以你最终用它自己替换了原来的撇号。

试试这样:

<xsl:variable name="apos">'</xsl:variable>
<xsl:value-of select="translate(text(), $apos, '&#8217;')"/>

最新更新