我有一个XSL模板:
<meta name="description" content="{$page-description}"/>
和变量:
<xsl:variable name="page-description">
<xsl:choose>
<xsl:when test="$current-page = 'home'">
<xsl:text>Lots of umlauts äöü</xsl:text>
</xsl:when>
<xsl:otherwise>
...
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
但是,似乎在XLS属性中不允许使用变音符号?
因为而不是我真正想要的,我得到了这个:
Lots of umlauts äöü
如何解决这个问题?
答案 0 :(得分:1)
无法重现。以下转变:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="yes" indent="yes"/>
<xsl:variable name="vTest">Lots of umlauts äöü</xsl:variable>
<xsl:template match="/">
<meta name="description" content="{$vTest}"/>
</xsl:template>
</xsl:stylesheet>
使用以下任何XSLT处理器运行:MSXML3,MSXML4,MSXML6,Saxon 6.1.4,Saxon9.1.7, AltovaXML(XML-SPY),.NET XslCompiledTransform,.NET XslTransform,生成完全相同的输出:
<meta name="description" content="Lots of umlauts äöü"/>
可能的解决方案:
在<xsl:output>
说明中,除了encoding
外,不要对utf-8
属性使用任何其他值。请尝试使用:<xsl:output encoding="utf-8"/>
如果使用结果的其他序列化(XmlWriter,TextWriter,...等),请确保为此附加序列化指定的编码为utf-8
确保您使用编码utf-8
及其默认字体查看结果的工具具有适当的特殊字符表示(例如,名为Arial Unicode MS
的字体具有大多数unicode字符的正确表示。)
答案 1 :(得分:0)
原来这个问题与我使用的内容管理系统有关,即Symphony(顺便推荐!)。
我通过将输出方法从xml更改为html来解决它。