Jeffrey Chan
Jeffrey Chan

Reputation: 93

xslt transformation to html encoding UTF-8

this is the xml:

<?xml version="1.0" encoding="UTF-8"?>
<title>中文字Chinese charactors 1234</title>

this is the xslt:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fn="http://www.w3.org/2005/xpath-functions">
    <xsl:output method="html" version="1.0" encoding="UTF-8" indent="yes"/>
    <xsl:template match="/">
    <xsl:value-of select="title"/>
    </xsl:template>
</xsl:stylesheet>

But the output seems encoding error as below:

銝剜��hinese charactors 1234

I make sure that the encoding is using "Unicode UTF-8" The software i am using is Altova XMLSpy Why is this happening and how to solve, thank you very much for your help. : )

Upvotes: 1

Views: 4210

Answers (1)

Michael Kay
Michael Kay

Reputation: 163312

Unfortunately, encoding errors always happen in the parts of the system that you don't bother to tell us about because you don't realise they are relevant.

First, check that the XSLT processor is doing serialization (not, for example, writing the result tree to a DOM) and that the serialization is to a binary output destination rather than a character destination. Then check the actual bytes in this binary destination. Eliminate all possibility that the error is in the way you are decoding these bytes while displaying them, rather than in the bytes themselves.

Upvotes: 1

Related Questions