Re: [xsl] XML transformation output to be in NON UTF-16 on MSXML 3.0.

Subject: Re: [xsl] XML transformation output to be in NON UTF-16 on MSXML 3.0.
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Mon, 22 Jul 2002 18:08:23 +0100
Brad Miller wrote:
> I just read this in the Microsoft XML 4.0 parser SDK help.
> If you want the output to be SHIFT-JIS you need to declare it like
> this <?xml version="1.0" encoding="Shift-JIS"?>
> I would assume that this is the same for 3.0 but I can't verify that.

Either the help's wrong or Brad's interpreting it incorrectly (or
perhaps I'm misinterpreting what Brad's saying). The encoding
specified by an XML declaration indicates the encoding for the XML
document in which the XML declaration is used. Changing the encoding
for the stylesheet (what I think Brad's suggesting) will have no
effect on the encoding used in the output of the transformation.

The only thing within XSLT that does have an effect on the encoding
used in the output of the transformation is the encoding attribute on
xsl:output:

<xsl:output encoding="Shift-JIS" />

but that only has an effect if the XSLT processor has control of the
serialization of the result constructed through the transformation.

When you use MSXML to run a transformation, if you access the result
of the transformation as a string, the string is always in UTF-16
because MSXML's XSLT processor isn't in charge of the serialization.
To put the XSLT processor in charge of the serialization, and thus get
a different encoding, you need to send the result of the
transformation to an object rather than access it as a string. See the
MSXML documentation on the 'output' property of IXSLProcessor for a
description.

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/


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


Current Thread