[Mono-dev] XmlTextWriter: order of namespace declarations

Gert Driesen gert.driesen at telenet.be
Thu Feb 9 04:43:14 EST 2006


Apparently the order in which namespace declarations are written by
Xml(Text)Writer differs between Mono and MS.NET.

I know this is very much implementation specific, and the fact that the
order is different in Mono is definitely not a bug.

However, this makes it difficult to write unit tests that pass on both Mono
and MS.NET for parts of Mono where XmlTextWriter is used internally.

To reproduce this "issue" (its not a bug, I know), compile and execute the
following code snippet:

using System;
using System.IO;
using System.Xml;

public class EntryPoint
	static void Main ()
		StringWriter sw = new StringWriter ();

		XmlTextWriter xtw = new XmlTextWriter (sw);
		xtw.WriteStartElement ("x", "some:urn");
		xtw.WriteAttributeString (null, "type",
"http://www.w3.org/2001/XMLSchema-instance", "string");
		xtw.WriteEndElement ();
		xtw.Flush ();

		Console.WriteLine (sw.ToString ());

Actual result:

<x d1p1:type="string" xmlns="some:urn"
xmlns:d1p1="http://www.w3.org/2001/XMLSchema-instance" />

Expected result:

<x d1p1:type="string" xmlns:d1p1="http://www.w3.org/2001/XMLSchema-instance"
xmlns="some:urn" />

Would it be possible to change our behaviour to match that of MS.NET ?


More information about the Mono-devel-list mailing list