![]() |
![]() | ![]() | ![]() | Altova Mailing List Archives>Archive Index >microsoft.public.xsl Archive Home >Recent entries >Thread Prev - Re: .NET security update broke transform engine? [Thread Next] Re: .NET security update broke transform engine?To: NULL Date: 7/14/2007 3:18:00 PM
OK, my StreamReader was not being set to the encoding of the Tranform OutputSetting Encoding. I was using this:
MemoryStream ms = new MemoryStream();
m_Transform.Transform(XmlData, TransformArgumentList, ms);
ms.Position = 0;
StreamReader sr = new StreamReader(ms);
So, something changed in this update because the server without the update was using UTF-8 encoding on the streamreader and it caused character 160 to
essentially be stripped in the output. On the server with the update it converted character 160 to 0xFFFD. So, I corrected my StreamReader but
something definitely changed in the update. The transform was transforming to ISO-8859-1 then the streamreader was converting it to UTF-8, previously
that was stripping character 160 from the output and now it converts it to character 0xFFFD.
Martin Honnen wrote:
> APA wrote:
>> I didn't say I was using the XslTransform class, I was generically
>> referring to the XslTransform engine in .NET (and this is a .NET 2.0
>> application). The issue is clearly a problem with the update as my
>> server that does not have the update doesn't produce the bad output
>> but the one with it does.
>>
>> Here's a real simple example that produces the bad output.
>>
>>
>> <xsl:stylesheet version="1.0"
>> xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
>> <xsl:output method="html" omit-xml-declaration="no"
>> encoding="ISO-8859-1" />
>>
>> <xsl:template match="/">
>> <b> </b>
>> </xsl:template>
>>
>> </xsl:stylesheet>
>>
>>
>> This generates character xFFFD in the output where it produced a
>> proper space character previously.
>
> I have a Windows XP system here that on Wednesday got the security
> update for KB928365. Using your stylesheet I made the following complete
> test case
>
> using System;
> using System.Collections.Generic;
> using System.Text;
> using System.IO;
> using System.Xml;
> using System.Xml.Xsl;
>
> namespace ConsoleApplication106
> {
> class Program
> {
> static void Main(string[] args)
> {
> XslCompiledTransform xsltProcessor = new
> XslCompiledTransform();
> xsltProcessor.Load(XmlReader.Create(new
> StringReader(@"<xsl:stylesheet
> xmlns:xsl=""http://www.w3.org/1999/XSL/Transform"" version=""1.0"">
> <xsl:output method=""html"" indent=""no"" encoding=""ISO-8859-1""/>
> <xsl:template match=""/""><b> </b></xsl:template>
> </xsl:stylesheet>")));
> MemoryStream memStream = new MemoryStream();
> xsltProcessor.Transform(XmlReader.Create(new
> StringReader(@"<dummy/>")), null, memStream);
> memStream.Position = 0;
> StreamReader streamReader = new StreamReader(memStream,
> xsltProcessor.OutputSettings.Encoding);
> string contents = streamReader.ReadToEnd();
> streamReader.Close();
> foreach (char c in contents)
> {
> Console.WriteLine("Character '{0}' with codepoint {1}.",
> c, (int)c);
> }
> }
> }
> }
>
> The output on the console is
>
> Character '<' with codepoint 60.
> Character 'b' with codepoint 98.
> Character '>' with codepoint 62.
> Character ' ' with codepoint 160.
> Character '<' with codepoint 60.
> Character '/' with codepoint 47.
> Character 'b' with codepoint 98.
> Character '>' with codepoint 62.
>
> so the non-breaking space (character 160) is correctly included in the
> output.
>
> I can't reproduce the problem you describe.
>
>
| ![]() | ![]() | ![]() |
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | |||||
|
