This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: UTF-8 Output


Jim Schmidt wrote:
> <xsl:output method="html" indent="yes" xalan:indent-amount="4"
> encoding="UTF-8" />

OK, you have gien a hint to the XSLT processor that after it is done
constructing the result tree, you would like it to be serialized using HTML
4.0 syntax, if supported, with extra whitespace added for readability, and
the bytes of the output should represent characters according to the UTF-8
mechanism.

> Everything works very well except Unicode characters. I am using Xalan 2.0.
> When I look at the XSL trace the Unicode characters are correct but when I
> look at the HTML source some of the Unicode bytes have been converted to
> HTML entities. As a result Unicode characters are not displayed correctly in
> a browser. If I change the entities in the HTML back to the proper
> characters the page displays correctly.

It is left to the processor to decide when to emit HTML entity references or
numeric character references. This varies from processor to processor, and
since Netscrape's handling of entity references and character references
leaves much to be desired, there's not a lot that you can do for maximum
compatibility, other than post-process your output.

The formatting of your source document is immaterial; this is supposed to be
all resolved and abstracted away by the XML parser before it even reaches
the XSLT processor. Or at least, the XSLT processor is supposed to act as if
that is the case.
 
> The XML document also defines its encoding as UTF-8.

A document doesn't define its encoding, it declares it. That is, it already
has an encoding, and the prolog may happen to mention what it is, for the
benefit of the XML parser that is going to be reading it.

   - Mike
_____________________________________________________________________________
mike j. brown, software engineer at  |  xml/xslt: http://skew.org/xml/
webb.net in denver, colorado, USA    |  personal: http://hyperreal.org/~mike/

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]