[no subject]

From: "rupesh chavan" <rupesh_chavan@xxxxxxxxxxx>
Date: Sun, 21 Jul 2002 03:00:31 +0000
Hi all,


Requirement: To make XML transformation output to be in NON UTF-16 on MSXML 3.0. More precisely SHIFT-JIS.


Problem: .xml method output is UTF-16 BSTR format .loadXML method takes input only as BSTR which is again in only UTF-16 The output of the transformation is in UTF-16 The value that we have on reading the output method of IXSLProcessor is UTF-16 eventhough it can do it in the encoding specified in the xsl:output if provided with a custom output. (MSXML 3.0 SDK help on output method)


Understanding: if i want the output in SHIFT_JIS for the tranformation i have only one option: To give the custom output to the output method of the tranform method.


Can any one validate if my understanding is right. a sample file i tried is also noted here =================================== <html> <META http-equiv="Content-Type" content="text/html; charset=x-sjis"> <button onclick="tryTranformations()">Try the transformations</button>


<xml id="style"> <?xml version="1.0" encoding="x-sjis"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; version ="1.0"> <xsl:output method="html"/> <xsl:param name="param1"/> <xsl:template match="/"> <some>something here<xsl:value-of select="." /> after</some> </xsl:template> </xsl:stylesheet> </xml>


<xml id=xmlDoc> <?xml version="1.0" encoding="x-sjis"?> <books> <book isbn="0345374827"> <title>The Great Shark Hunt</title> <author>Hunter S. Thompson</author> </book> </books> </xml>


<script language=JScript> function tryTranformations() { //the transformNode cannot be used, //the loadXML method cannot be used //the .xml method cannot be used //because all of hte above return only UTF-16 string as per the //Q275883 support INFO document. //So the only avenue open is to use the output method of the IXSLTProcessor.


var xslt = new ActiveXObject("Msxml2.XSLTemplate"); var xslDoc = new ActiveXObject("Msxml2.FreeThreadedDOMDocument"); var xslProc; xslDoc.async = false; xslDoc.loadXML(document.all.style.xml); xslt.stylesheet = xslDoc; /* //cannot use the three lines below, because the specification states that the loadXML method //takes as input only the BSTR which is of UTF-16 format. var xmlDoc = new ActiveXObject("Msxml2.DOMDocument"); xmlDoc.async = false; xmlDoc.loadXML(document.all.source.xml);*/ xslProc = xslt.createProcessor(); xslProc.input = xmlDoc.XMLDocument; var xmlSink = new ActiveXObject("Msxml2.DOMDocument");


//The documenation says that if we try to read the property, then its converted into UTF-16. //So trying to give as input any of the objects which can work with the ISream interface write method. try { xslProc.transform(); xslProc.output(xmlSink); alert("SUCCESSFUL in serialising in xmlSink DOM object "); } catch (e) { alert("Cannot be serialised in xmlSink DOM object " + e.description); }


try { xslProc.transform(); xslProc.output(xmlSink.load); alert("SUCCESSFUL in serialising in xmlSink Load method "); } catch (e) { alert("Cannot be serialised in xmlSink load method " + e.description); }


try { xslProc.transform(); xslProc.output(xmlSink.loadXML); alert("SUCCESSFUL in serialising in xmlSink LoadXML method "); } catch (e) { alert("Cannot be serialised in xmlSink loadXML method " + e.description); }


try { xslProc.transform(); xslProc.output(document); //might be document.write used IStream alert("SUCCESSFUL in serialising in document object "); } catch (e) { alert("Cannot be serialised in document object " + e.description); }


//So any way to get the output of the transformation only in SHIFT_JIS } </script> </html>


===================================



Or can can one suggest anyother method to get SHIFT_JIS as the output of a tranformation. Basically is it feasible. with MSXML 3.0 on IE.


Thanks, Rupesh, Internet consultant, Tata Consultancy Services.




_________________________________________________________________ Chat with friends online, try MSN Messenger: http://messenger.msn.com


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



Current Thread
  • [no subject]
    • rupesh chavan - Sun, 21 Jul 2002 03:00:31 +0000 <=