[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: XML transformation output to be in NON UTF-16 on M
--- "rupesh chavan" <rupesh_chavan at hotmail dot com> wrote: > > 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 > =================================== > > Try the transformations > > > > =================================== Hi Rupesh, There are two things to note: 1. The result of the transformation must not be assigned to a variable of type string, as MSXML is a COM object and strings in COM are of the BSTR type (UTF-16). One choice is to assign the Response object to the output property of IXSLProcessor before invoking the IXSLProcessor.transform() method. This is possible server side within an ASP page. As the MSXML SDK documentation states, "The output property can be any object/interface that supports IStream, IPersistStream, DOMDocument, ASP IResponse, ADODB.Stream, or IMXWriter. When a new transform is started, the processor will use a QueryInterface this output for IStream. When the transform is complete or reset is called, IStream is released. The only method that is used on IStream is Write. The bytes written to the stream will be encoded according to the encoding attribute on the <xsl:output> element." Therefore, another object that supports the IStream interface may be used client-side -- e.g. ADODB.Stream. One will create an instance of an ADODB.Stream, then assign it to the output property of the IXSLProcessor instance, then invoke transform() on the IXSLProcessor instance. A good XSLT programming environment will do this for you and the result in the correct encoding will be displayed. For example, I used XSelerator. A small sample xml document like this: <?xml version="1.0" encoding="Shift-JIS" ?> <text>ム メ モ</text> is being transformed applying this transformation: <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="html" encoding="Shift-JIS"/> <xsl:template match="/"> <html> <head/> <xsl:value-of select="."/> </html> </xsl:template> </xsl:stylesheet> The result contains a correct <META http-equiv="Content-Type" content="text/html; charset=Shift-JIS"> within the <head> element IE displays the three correct Japanese characters -- exactly as it should. One final note -- I have the Arial Unicode MS font installed. ===== Cheers, Dimitre Novatchev. http://fxsl.sourceforge.net/ -- the home of FXSL __________________________________________________ Do You Yahoo!? Yahoo! Health - Feel better, live better http://health.yahoo.com XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|