我有Word XML文件,我使用XLST文件将其转换为html。在转换过程中,我需要将Word中的Wingdings符号转换为Unicode。我的XSLT中有以下代码:
<xsl:template match="w:sym">
<xsl:choose>
<xsl:when test="@w:char='F0FE'">
<span>☑</span>
</xsl:when>
<xsl:when test="@w:char='F054'">
<span>☒</span>
</xsl:when>
<xsl:otherwise>
<span>
<xsl:attribute name="style">
font-family:<xsl:value-of select="@w:font"/>
</xsl:attribute>
<xsl:choose>
<xsl:when test="starts-with(@w:char, 'F0')">
<xsl:text disable-output-escaping="yes">&</xsl:text>#x<xsl:value-of select="substring-after(@w:char, 'F0')"/><xsl:text>;</xsl:text>
</xsl:when>
<xsl:when test="starts-with(@w:char, 'f0')">
<xsl:text disable-output-escaping="yes">&</xsl:text>#x<xsl:value-of select="substring-after(@w:char, 'f0')"/><xsl:text>;</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text disable-output-escaping="yes">&</xsl:text>#x<xsl:value-of select="@w:char"/><xsl:text>;</xsl:text>
</xsl:otherwise>
</xsl:choose>
</span>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
我的问题是,我在MicrosoftWebDeveloperExpress中遇到一个错误,span块显示十进制数中的无效字符。关于如何使用unicode符号并将其正确转换为html,有什么想法吗?
是的,数字后面应该有一个分号,否则它们就不是字符实体。
至于为什么你看到的是"?"而不是实际的字形,这取决于程序(MS Web Developer Express?(使用的字体是否包含所使用的代码点的字形。您的数据可能是正确的,但并不是每个字体或程序都能显示所有字符。
本页列出了一些支持Unicode字符9745(x2611(的字体。您的浏览器显示为:☑;