xsl-list
[Top] [All Lists]

RE: MSXML2 and encoding

2003-08-19 14:49:35
Hi

-----Original Message-----
From: owner-xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com 
[mailto:owner-xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com] On Behalf Of 
Teresa Rippeon
Sent: Tuesday, August 19, 2003 9:44 PM
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] MSXML2 and encoding 



Whenever I tranform one XML file to another using MSXML2, I 

You are not using MSXML2 but MSXML3. the object name is MSXML2 but the
version is not
Besides MSXML2 doesn't support xslt


get the XML processing instruction with an encoding value of 
"UTF-16" ( <?xml version="1.0" encoding = "UTF-16">). Of 
course, then when the file is launched in IE 6, I get the 
error that it can't switch to the specified encoding. I 
really just want either no encoding specified or encoding = 
"UTF-8". I've even tried specifying an encoding of "UTF-8". 
Any advice?

Here's the beginning of my stylesheet:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" 
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
xmlns:fo="http://www.w3.org/1999/XSL/Format";>

<xsl:output indent="yes" media-type="xml" 
encoding="UTF-8"></xsl:output>


And here's the VB code for using MSXML2, if that helps...

      'Load the XML data
      Set source_xml = New MSXML2.DOMDocument30

Here you define the version you are using. DOMDocument30 is MSXML3

      source_xml.async = False
      source_xml.Load (source_doc)
      If (source_xml.parseError.errorCode <> 0) Then
        GoTo Errorhandling
      End If
      
      'Load the stylesheet
      Set tranform_stylesheet = New MSXML2.DOMDocument30
      tranform_stylesheet.async = False
      tranform_stylesheet.Load (stylesheet_doc)
      If (tranform_stylesheet.parseError.errorCode <> 0) Then
        GoTo Errorhandling
      End If

      new_xml_string = source_xml.transformNode(tranform_stylesheet)

Here lies your problem. You are setting the result of your transformation to
a string variable. In this way you always get encoding="utf-16", the
encoding used by strings in VB 

You need to use transformNodeToObject method and serialize the
transformation to a stream. If you are doing this on the server in an asp
page you can serialize directly to the response object like:
 source_xml.transformNodeToObject(transform_stylesheet, Response)

Regards,
Americo Albuquerque


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



<Prev in Thread] Current Thread [Next in Thread>