[Mono-list] System.Xml bug

Jaroslaw Kowalski jarek@atm.com.pl
Sat, 26 Oct 2002 23:11:01 +0200


This is a multi-part message in MIME format.

------=_NextPart_000_0015_01C27D44.F39806B0
Content-Type: text/plain;
	charset="iso-8859-2"
Content-Transfer-Encoding: 7bit

Hi all!

Looks like there's been some regression in System.Xml classes:
Consider the (kind of trivial) code in xmlbug.cs (attached) and test.xml
(also attached)

On .NET it runs ok. On Mono, it produces:
========
Unhandled Exception: System.InvalidOperationException: The requested
operation cannot be performed
in <0x000b1> 00 System.Xml.XmlDocumentNavigator:get_NodeType ()
in <0x00020> 00 System.Xml.XPath.NodeNameTest:Match
(System.Xml.Xsl.XsltContext,System.Xml.XPath.XPathNavigator)
in <0x00034> 00 System.Xml.XPath.AxisIterator:MoveNext ()
in <0x0001a> 00 System.Xml.XPath.SlashIterator:MoveNext ()
in <0x0010e> 00 System.Xml.XmlNode:SelectNodes
(string,System.Xml.XmlNamespaceManager)
in <0x0006d> 00 .Bug1:Main (string[])
========

I found that the problem is related to innocent '<?xml version="1.0" ?>' at
the top of 'test.xml'. If I remove it, everything is OK.
I'm 100% sure that it used to work properly on mono but is broken for some
time now.

Regards,

Jarek

------=_NextPart_000_0015_01C27D44.F39806B0
Content-Type: text/plain;
	name="xmlbug.cs"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
	filename="xmlbug.cs"

using System;
using System.Xml;

public class Bug1
{
	public static void Main(string[] args)
	{
		XmlDocument doc = new XmlDocument();

		doc.Load("test.xml");

		foreach (XmlElement el in doc.SelectNodes("xxx/yyy"))
		{
			Console.WriteLine(el.InnerXml);
		}
	}
};
------=_NextPart_000_0015_01C27D44.F39806B0
Content-Type: text/xml;
	name="test.xml"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
	filename="test.xml"

<?xml version="1.0" ?>
<xxx>
    <yyy>item1</yyy>
    <yyy>item2</yyy>
    <yyy>item3</yyy>
    <yyy>item4</yyy>
</xxx>

------=_NextPart_000_0015_01C27D44.F39806B0--