RE: [xsl] encoding issues

Subject: RE: [xsl] encoding issues
From: "Julian Reschke" <julian.reschke@xxxxxx>
Date: Wed, 3 Jul 2002 12:23:10 +0200
> From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx]On Behalf Of Andrew Welch
> Sent: Wednesday, July 03, 2002 12:03 PM
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: RE: [xsl] encoding issues
>
>
>
>
> >I think what's going on is that you're expecting to "see" the result of
> >putting a space or sequence of spaces into the xml file when you view
> >the xml file in IE(or is it that you want the whitespace to be
> >maintained on output itself?). That won't happen since xml files are
> >supposed to ignore whitespace, now if you put xml:space="preserve" as
> an
> >attribute on the element you want the whitespace to be significant in
> my
> >understanding is that it should be displayed.
> >However my experience with IE is that it does not display it, perhaps
> >this is a bug in the Defaultss.xsl.
>
>
> preserving whitespace only preserves whitespace only text nodes, which
> is a different matter.  What I am wondering is:
>
> 1. How IE decides which encoding to use
> 2. Why MSXML4 doesnt output unicode if you specify encoding="utf-8" in
> xsl:output
> 3. Why, when using output encoding="utf-16", msxml4 gives me unicode and
> saxon doesnt
>
> nb. when I say 'gives me', I mean IE autoselects that encoding.
>
> Please test it yourself:
>
> ==xml==
> <?xml version="1.0" encoding="UTF-8"?>
> <root>
>   <node>foo&#160;bar</node>
> </root>
>
> ==xsl==
> <xsl:stylesheet
> 	xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
> 	version="1.0">
> <xsl:output method="xml" encoding="utf-8"/>
> <xsl:template match="root">
>   <xsl:value-of select="node"/>
> </xsl:template>
> </xsl:stylesheet>
>
> Run the transformation using msxml and saxon and then let me know
> encoding IE selects (of course make sure auto-select is checked).
>
> I get something like fooAbar where the 'A' is the unrecognised character
> symbol.

The problem is that the output of your transformation is labelled as XML,
but the XML is not well-formed (missing document element).

Even if the transformation result *would* be wellformed XHTML, this wouldn't
work, as IE does not support XHTML (properly).

So the only clean solution is to produce HTML using the "html" xsl:output
method. This will insert the proper META tag (which IE requires to detect
the encoding).


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


Current Thread