im messing with encodings.
On the one hand, I have a url that answers me in UTF-8 (I'm pretty sure, thanks to the firebug plugin).
Im opens a URL reading the contents in UTF-8 using the following code:
StreamReader reader = new StreamReader(response.GetResponseStream(),System.Text.Encoding.UTF8);
On the other hand, I have an xslt conversion sheet with the following code:
<?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl"> <xsl:output method="xml" indent="yes"/> <xsl:template match="@* | node()"> <xsl:copy> <xsl:apply-templates select="@* | node()"/> <br/> hello </xsl:copy> </xsl:template> </xsl:stylesheet>
This xslt sheet is also saved in UTF-8 format.
I use the following code to mix xml with xslt:
StringWriter writer = new StringWriter(); XslCompiledTransform transformer = new XslCompiledTransform(); transformer.Load(HttpContext.Current.Server.MapPath("xslt\\xsltsheet.xslt"); XmlWriterSettings xmlsettings = new XmlWriterSettings(); xmlsettings.Encoding = System.Text.Encoding.UTF8; transformer.Transform(xmlreader, null, writer); return writer;
Then, in the end, im renders the contents of this author in the webbrowser and im, receiving the following error:
XML page cannot be displayed. Cannot view XML input using sheet style. Correct the error and then click the Refresh button or try again later.
Switching from the current encoding to the specified encoding is not supported. Error handling resource ' http: // localhost: 2541 / Results ....
<?xml version="1.0" encoding="utf-16"?>
I wonder where to find the UTF-16 encoding, assume that:
- All my files are saved as UTF-8
- The response from the server is in UTF-8
- The xslt sheet reading method is configured as UTF-8.
Any help would be appreciated.
Thanks in advance.
Best wishes.
Jose.