简体   繁体   中英

Word XML - XSLT to HTML

I have Word XML files that I convert to html with the use of an XLST file. I need to convert Wingdings symbols in Word to Unicode during the conversion. I have the following code in my XSLT:

<xsl:template match="w:sym">
    <xsl:choose>          
        <xsl:when test="@w:char='F0FE'">
            <span>&#9745</span>
        </xsl:when>            
        <xsl:when test="@w:char='F054'">
            <span>&#9746</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">&amp;</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">&amp;</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">&amp;</xsl:text>#x<xsl:value-of select="@w:char"/><xsl:text>;</xsl:text>
                    </xsl:otherwise>
                </xsl:choose>
            </span>
        </xsl:otherwise>
    </xsl:choose>
</xsl:template>

My problem is that I get an error in Microsoft Web Developer Express with the span blocks saying invalid character in decimal number. Any ideas on how else to use the unicode symbols and have them convert to html correctly?

Yes, you should have a semicolon after the number - otherwise they won't be character entities.

As for why you're seeing "?" instead of the actual glyphs, this depends on whether the font being used by the program (MS Web Developer Express?) contains glyphs for the codepoints being used. Your data may be correct, but not every font or program will be able to display all the characters.

This page lists some fonts that support Unicode character 9745 (x2611). Your browser shows it as: ☑

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM