[Mono-list] System.Xml bug

Piers Haken piersh@friskit.com
Sat, 26 Oct 2002 15:39:24 -0700


This is a multi-part message in MIME format.

------_=_NextPart_001_01C27D40.88ED74FC
Content-Type: text/plain;
	charset="US-ASCII"
Content-Transfer-Encoding: quoted-printable

It looks like XmlDocumentNavigator wasn't handling the xml declaration
node correctly. I have checked the following simple patch into cvs:

Index: XmlDocumentNavigator.cs
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file:
/cvs/public/mcs/class/System.XML/System.Xml/XmlDocumentNavigator.cs,v
retrieving revision 1.4
diff -u -r1.4 XmlDocumentNavigator.cs
--- XmlDocumentNavigator.cs	13 Sep 2002 02:15:40 -0000	1.4
+++ XmlDocumentNavigator.cs	26 Oct 2002 22:25:28 -0000
@@ -123,7 +123,7 @@
 				case XmlNodeType.ProcessingInstruction:
 					return
XPathNodeType.ProcessingInstruction;
 				}
-				throw new InvalidOperationException ();
+				return (XPathNodeType) (-1);
 			}
 		}
=20

Piers.

> -----Original Message-----
> From: Jaroslaw Kowalski [mailto:jarek@atm.com.pl]=20
> Sent: Saturday, October 26, 2002 2:11 PM
> To: mono-list@ximian.com
> Subject: [Mono-list] System.Xml bug
>=20
>=20
> Hi all!
>=20
> Looks like there's been some regression in System.Xml=20
> classes: Consider the (kind of trivial) code in xmlbug.cs=20
> (attached) and test.xml (also attached)
>=20
> On .NET it runs ok. On Mono, it produces:
> =3D=3D=3D=3D=3D=3D=3D=3D
> Unhandled Exception: System.InvalidOperationException: The=20
> requested operation cannot be performed in <0x000b1> 00=20
> System.Xml.XmlDocumentNavigator:get_NodeType () in <0x00020>=20
> 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[])
> =3D=3D=3D=3D=3D=3D=3D=3D
>=20
> I found that the problem is related to innocent '<?xml=20
> version=3D"1.0" ?>' at the top of 'test.xml'. If I remove it,=20
> everything is OK. I'm 100% sure that it used to work properly=20
> on mono but is broken for some time now.
>=20
> Regards,
>=20
> Jarek
>=20

------_=_NextPart_001_01C27D40.88ED74FC
Content-Type: text/html;
	charset="US-ASCII"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; =
charset=3Dus-ascii">
<META NAME=3D"Generator" CONTENT=3D"MS Exchange Server version =
6.0.4417.0">
<TITLE>RE: [Mono-list] System.Xml bug</TITLE>
</HEAD>
<BODY>
<!-- Converted from text/plain format -->

<P><FONT SIZE=3D2>It looks like XmlDocumentNavigator wasn't handling the =
xml declaration node correctly. I have checked the following simple =
patch into cvs:</FONT></P>

<P><FONT SIZE=3D2>Index: XmlDocumentNavigator.cs</FONT>

<BR><FONT =
SIZE=3D2>=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D</FONT>

<BR><FONT SIZE=3D2>RCS file: =
/cvs/public/mcs/class/System.XML/System.Xml/XmlDocumentNavigator.cs,v</FO=
NT>

<BR><FONT SIZE=3D2>retrieving revision 1.4</FONT>

<BR><FONT SIZE=3D2>diff -u -r1.4 XmlDocumentNavigator.cs</FONT>

<BR><FONT SIZE=3D2>--- XmlDocumentNavigator.cs&nbsp;&nbsp;&nbsp;&nbsp; =
13 Sep 2002 02:15:40 -0000&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1.4</FONT>

<BR><FONT SIZE=3D2>+++ XmlDocumentNavigator.cs&nbsp;&nbsp;&nbsp;&nbsp; =
26 Oct 2002 22:25:28 -0000</FONT>

<BR><FONT SIZE=3D2>@@ -123,7 +123,7 @@</FONT>

<BR><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; case =
XmlNodeType.ProcessingInstruction:</FONT>

<BR><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return =
XPathNodeType.ProcessingInstruction;</FONT>

<BR><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</FONT>

<BR><FONT SIZE=3D2>-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; throw new =
InvalidOperationException ();</FONT>

<BR><FONT SIZE=3D2>+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return (XPathNodeType) =
(-1);</FONT>

<BR><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</FONT>

<BR><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</FONT>

<BR><FONT SIZE=3D2>&nbsp;</FONT>
</P>

<P><FONT SIZE=3D2>Piers.</FONT>
</P>

<P><FONT SIZE=3D2>&gt; -----Original Message-----</FONT>

<BR><FONT SIZE=3D2>&gt; From: Jaroslaw Kowalski [<A =
HREF=3D"mailto:jarek@atm.com.pl">mailto:jarek@atm.com.pl</A>] </FONT>

<BR><FONT SIZE=3D2>&gt; Sent: Saturday, October 26, 2002 2:11 PM</FONT>

<BR><FONT SIZE=3D2>&gt; To: mono-list@ximian.com</FONT>

<BR><FONT SIZE=3D2>&gt; Subject: [Mono-list] System.Xml bug</FONT>

<BR><FONT SIZE=3D2>&gt; </FONT>

<BR><FONT SIZE=3D2>&gt; </FONT>

<BR><FONT SIZE=3D2>&gt; Hi all!</FONT>

<BR><FONT SIZE=3D2>&gt; </FONT>

<BR><FONT SIZE=3D2>&gt; Looks like there's been some regression in =
System.Xml </FONT>

<BR><FONT SIZE=3D2>&gt; classes: Consider the (kind of trivial) code in =
xmlbug.cs </FONT>

<BR><FONT SIZE=3D2>&gt; (attached) and test.xml (also attached)</FONT>

<BR><FONT SIZE=3D2>&gt; </FONT>

<BR><FONT SIZE=3D2>&gt; On .NET it runs ok. On Mono, it produces:</FONT>

<BR><FONT SIZE=3D2>&gt; =3D=3D=3D=3D=3D=3D=3D=3D</FONT>

<BR><FONT SIZE=3D2>&gt; Unhandled Exception: =
System.InvalidOperationException: The </FONT>

<BR><FONT SIZE=3D2>&gt; requested operation cannot be performed in =
&lt;0x000b1&gt; 00 </FONT>

<BR><FONT SIZE=3D2>&gt; System.Xml.XmlDocumentNavigator:get_NodeType () =
in &lt;0x00020&gt; </FONT>

<BR><FONT SIZE=3D2>&gt; 00 System.Xml.XPath.NodeNameTest:Match</FONT>

<BR><FONT SIZE=3D2>&gt; =
(System.Xml.Xsl.XsltContext,System.Xml.XPath.XPathNavigator)</FONT>

<BR><FONT SIZE=3D2>&gt; in &lt;0x00034&gt; 00 =
System.Xml.XPath.AxisIterator:MoveNext ()</FONT>

<BR><FONT SIZE=3D2>&gt; in &lt;0x0001a&gt; 00 =
System.Xml.XPath.SlashIterator:MoveNext ()</FONT>

<BR><FONT SIZE=3D2>&gt; in &lt;0x0010e&gt; 00 =
System.Xml.XmlNode:SelectNodes</FONT>

<BR><FONT SIZE=3D2>&gt; (string,System.Xml.XmlNamespaceManager)</FONT>

<BR><FONT SIZE=3D2>&gt; in &lt;0x0006d&gt; 00 .Bug1:Main =
(string[])</FONT>

<BR><FONT SIZE=3D2>&gt; =3D=3D=3D=3D=3D=3D=3D=3D</FONT>

<BR><FONT SIZE=3D2>&gt; </FONT>

<BR><FONT SIZE=3D2>&gt; I found that the problem is related to innocent =
'&lt;?xml </FONT>

<BR><FONT SIZE=3D2>&gt; version=3D&quot;1.0&quot; ?&gt;' at the top of =
'test.xml'. If I remove it, </FONT>

<BR><FONT SIZE=3D2>&gt; everything is OK. I'm 100% sure that it used to =
work properly </FONT>

<BR><FONT SIZE=3D2>&gt; on mono but is broken for some time now.</FONT>

<BR><FONT SIZE=3D2>&gt; </FONT>

<BR><FONT SIZE=3D2>&gt; Regards,</FONT>

<BR><FONT SIZE=3D2>&gt; </FONT>

<BR><FONT SIZE=3D2>&gt; Jarek</FONT>

<BR><FONT SIZE=3D2>&gt; </FONT>
</P>

</BODY>
</HTML>
------_=_NextPart_001_01C27D40.88ED74FC--