Re: IE error

[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: IE error | Switch from current encoding to specifi

Subject: Re: IE error | Switch from current encoding to specified encoding not supported.
From: Abel Braaksma <abel.online@xxxxxxxxx>
Date: Wed, 03 Oct 2007 19:34:18 +0200
Re:  IE error | Switch from current encoding to specifi
Hi Steve, William,

This is one way to do it. The source of the original problem was actually with the settings for the internal XML Writer, which defaults to UTF-16 (partially true, real UTF-16 is not supported by Microsoft, notably, MS does not support surrogate pairs) and if you "just" write the results of an XsltProcessor, it ends up being UTF-16.

By setting a custom writer with your properties, for the encoding you will effectively create the correct output stream in one go, without having to use Response.Write.Replace. I.e., in C# it looks a bit like this:

// instantiate an XmlWriter
XmlWriter xmlWriter = XmlWriter.Create("output.xml");
xmlWriter.Settings.Encoding = "UTF-8"; XslCompiledTransform xslt = new XslCompiledTransform(true);


   // enable document function and scripting
   XsltSettings xsltSettings = new XsltSettings(true, true);

// load stylesheet and transform to "output.xml" (but you can use any stream)
xslt.Load("Xslt/test.xslt", xsltSettings, null);
xmlWriter = XmlWriter.Create("output.xml");
xslt.Transform("Xslt/test.xslt", xsltArgs, xmlWriter);
xmlWriter.Close();



This is using the classes from ASP.NET 2.0 so you if you want to use this you may have to adjust it to your situation.


Cheers,
-- Abel Braaksma



W Charlton wrote:
Steve,

If you are using ASP then you will need to add a replace function.

Below is a snip of some code we use.

Set XSLTemp = Server.CreateObject(MSXML2.XSLTemplate.3.0)
      Set XSLTemp.stylesheet = XSLDoc 'variable set higher up in page e.g.
c:\myfiles\myxsl.xsl
      Set XSLProc = XSLTemp.createProcessor
      XSLProc.input = XMLDoc 'variable set higher up in page e.g.
c:\myfiles\myxsl.xml
      XSLProc.addParameter "MyParam", "MyParamValue"
     XSLProc.transform
     Response.Charset = "ISO-8859-15"

Response.Write Replace(XSLProc.output, "UTF-16", "ISO-8859-15")

If you want UTF-8 replace ISO-8859-15 (Latin 1 extended) with UTF-8


William Charlton The yMonda team yMonda Limited w: www.ymonda.net

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.