xsl-list
[Top] [All Lists]

Re: MSXML / NBSP problem and resolution

2002-11-06 17:39:04
Michael H. Semcheski wrote:
After a few hours of testing and looking through the archives, I figured 
out a solution I had not seen presented on this list.  I hope no one 
else is having the same problems, but I am posting this because I am 
sure that someone will.

I was working with active server pages (asp) and MSXML 3.0 to generate a 
page by transforming an XML document via an XSL stylesheet.  Nothing out 
of the ordinary.

The problem I was having was that no matter what character set I defined 
in the XSL document, there was a meta-tag being added that set the 
character set to UTF/16 ala:
content="text/html; charset=UTF-16"

There is a FAQ about MSXML and UTF-16 that's not in the aging MSXML FAQ.
Make sure you're not using Strings where you don't have to. This message 
from Andy Kimball at MS explains:

  http://www.biglist.com/lists/xsl-list/archives/200108/msg00541.html

This leads to Internet Explorer selecting Unicode as the encoding type 
when set to the default "Auto-Select" encoding.  I added the following 
at the top of the script:
Response.CharSet = "ISO8859-1"
The meta tag still comes through as charset=UTF-16, but the Auto-Select 
function selects Western (ISO), and instead of nbsps showing up as ? 
they display correctly.

As I understand it, "Auto-Select" in IE means "if there's no charset parameter
given in the Content-Type HTTP response header or in the equivalent META
element in the HTML document itself, then make an intelligent guess at the
document's encoding". So once you set Response.CharSet in the server, you
force the output to be transcoded to the encoding you choose, and it is
reported correctly in the HTTP headers, thus bypassing the auto-select logic 
in the client.

So your problem is just that you've still got the erroneous meta tag, right? I
think you will be able to fix it if you make sure that your stylesheet uses
<xsl:output method="html" encoding="iso-8859-1"/> and that you follow Andy's
examples to avoid storing your output in intermediate String objects.

   - Mike
____________________________________________________________________________
  mike j. brown                   |  xml/xslt: http://skew.org/xml/
  denver/boulder, colorado, usa   |  resume: http://skew.org/~mike/resume/

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