[Mono-list] [PATCH] System.XML build fixes and initial namespace support

Jason Diamond jason@injektilo.org
Sun, 10 Feb 2002 11:27:25 -0800


This is a multi-part message in MIME format.

------=_NextPart_000_000A_01C1B225.EA6A1780
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: 7bit

2002-02-10  Jason Diamond  <jason@injektilo.org>

 * System.XML.build: Renamed the System.Xml.dll assembly to 
 System.XML.dll to match Microsoft.

 * System.XML.build, Test/System.XML_test.build: Added tasks to 
 clean .dll and .pdb files.

 * System.XML.build, Test/System.XML_test.build: Copy System.XML.dll 
 to Test directory and reference that. This makes it so our tests 
 test our code and not Microsoft's.

 * System.Xml/XmlTextReader.cs: Added support for parsing prefixes 
 and local names.

 * Test/Test.cs: Updated all tests to test the prefix and local name 
 properties.


------=_NextPart_000_000A_01C1B225.EA6A1780
Content-Type: application/octet-stream;
	name="xml1.patch"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
	filename="xml1.patch"

? xml1.patch=0A=
Index: ChangeLog=0A=
=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=0A=
RCS file: /mono/mcs/class/System.XML/ChangeLog,v=0A=
retrieving revision 1.2=0A=
diff -u -r1.2 ChangeLog=0A=
--- ChangeLog	23 Jan 2002 19:19:33 -0000	1.2=0A=
+++ ChangeLog	10 Feb 2002 19:30:52 -0000=0A=
@@ -1,3 +1,21 @@=0A=
+2002-02-10  Jason Diamond  <jason@injektilo.org>=0A=
+=0A=
+	* System.XML.build: Renamed the System.Xml.dll assembly to =0A=
+	System.XML.dll to match Microsoft.=0A=
+=0A=
+	* System.XML.build, Test/System.XML_test.build: Added tasks to =0A=
+	clean .dll and .pdb files.=0A=
+=0A=
+	* System.XML.build, Test/System.XML_test.build: Copy System.XML.dll =0A=
+	to Test directory and reference that. This makes it so our tests =0A=
+	test our code and not Microsoft's.=0A=
+=0A=
+	* System.Xml/XmlTextReader.cs: Added support for parsing prefixes =0A=
+	and local names.=0A=
+=0A=
+	* Test/Test.cs: Updated all tests to test the prefix and local name =0A=
+	properties.=0A=
+=0A=
 2002-01-23  Dick Porter  <dick@ximian.com>=0A=
 =0A=
 	* System.Xml/XmlNode.cs: Fixed IndexerName attribute so it=0A=
Index: System.XML.build=0A=
=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=0A=
RCS file: /mono/mcs/class/System.XML/System.XML.build,v=0A=
retrieving revision 1.3=0A=
diff -u -r1.3 System.XML.build=0A=
--- System.XML.build	7 Dec 2001 10:53:20 -0000	1.3=0A=
+++ System.XML.build	10 Feb 2002 19:30:52 -0000=0A=
@@ -1,20 +1,20 @@=0A=
 <?xml version=3D"1.0" encoding=3D"iso-8859-1"?>=0A=
 =0A=
-<!-- NAnt build file for System.Xml.dll -->=0A=
+<!-- NAnt build file for System.XML.dll -->=0A=
 =0A=
-<project name=3D"System.Xml" default=3D"build">=0A=
+<project name=3D"System.XML" default=3D"build">=0A=
 	<property name=3D"debug" value=3D"false"/>=0A=
 =0A=
 	<target name=3D"build">=0A=
 		<mkdir dir=3D"../lib"/>=0A=
-		<csc target=3D"library" output=3D"../lib/System.Xml.dll" =
debug=3D"${debug}">=0A=
+		<csc target=3D"library" output=3D"../lib/System.XML.dll" =
debug=3D"${debug}">=0A=
 			<arg value=3D"/nowarn:1595"/>=0A=
-			<arg value=3D"/unsafe"/>=0A=
 			<sources>=0A=
 				<includes name=3D"**/*.cs"/> =0A=
 				<excludes name=3D"Test/**"/>=0A=
 			</sources>=0A=
 		</csc>=0A=
+		<copy file=3D"../lib/System.XML.dll" tofile=3D"Test/System.XML.dll"/>=0A=
 		<nant basedir=3D"Test" target=3D"build"/>=0A=
 	</target>=0A=
 =0A=
@@ -24,5 +24,7 @@=0A=
 =0A=
 	<target name=3D"clean">=0A=
 		<nant basedir=3D"Test" target=3D"clean"/>=0A=
+		<delete file=3D"../lib/System.XML.dll" failonerror=3D"false"/>=0A=
+		<delete file=3D"../lib/System.XML.pdb" failonerror=3D"false"/>=0A=
 	</target>=0A=
 </project>=0A=
Index: System.Xml/XmlTextReader.cs=0A=
=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=0A=
RCS file: /mono/mcs/class/System.XML/System.Xml/XmlTextReader.cs,v=0A=
retrieving revision 1.2=0A=
diff -u -r1.2 XmlTextReader.cs=0A=
--- System.Xml/XmlTextReader.cs	19 Jul 2001 19:21:59 -0000	1.2=0A=
+++ System.Xml/XmlTextReader.cs	10 Feb 2002 19:30:56 -0000=0A=
@@ -270,8 +270,7 @@=0A=
 		{
 			get
 			{
-				// TODO: implement me.
-				return null;
+				return localName;
 			}
 		}
=20
@@ -341,8 +340,7 @@=0A=
 		{
 			get
 			{
-				// TODO: implement me.
-				return null;
+				return prefix;
 			}
 		}
=20
@@ -562,6 +560,8 @@=0A=
=20
 		private XmlNodeType nodeType;
 		private string name;
+		private string prefix;
+		private string localName;
 		private bool isEmptyElement;
 		private string value;
 		private Hashtable attributes;
@@ -588,6 +588,8 @@=0A=
=20
 			nodeType =3D XmlNodeType.None;
 			name =3D String.Empty;
+			prefix =3D String.Empty;
+			localName =3D string.Empty;
 			isEmptyElement =3D false;
 			value =3D String.Empty;
 			attributes =3D new Hashtable();
@@ -624,6 +626,19 @@=0A=
 			if (clearAttributes)
 			{
 				ClearAttributes();
+			}
+
+			int indexOfColon =3D name.IndexOf(':');
+
+			if (indexOfColon =3D=3D -1)
+			{
+				prefix =3D String.Empty;
+				localName =3D name;
+			}
+			else
+			{
+				prefix =3D name.Substring(0, indexOfColon);
+				localName =3D name.Substring(indexOfColon + 1);
 			}
 		}
=20
Index: Test/System.XML_test.build=0A=
=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=0A=
RCS file: /mono/mcs/class/System.XML/Test/System.XML_test.build,v=0A=
retrieving revision 1.2=0A=
diff -u -r1.2 System.XML_test.build=0A=
--- Test/System.XML_test.build	8 Nov 2001 11:35:50 -0000	1.2=0A=
+++ Test/System.XML_test.build	10 Feb 2002 19:30:56 -0000=0A=
@@ -10,14 +10,14 @@=0A=
 =0A=
 	<target name=3D"build">=0A=
 		<csc target=3D"library" output=3D"System.XML_test.dll" =
debug=3D"${debug}">=0A=
+			<arg value=3D"/nowarn:1595"/>=0A=
 			<sources>=0A=
 				<includes name=3D"**/*.cs"/>=0A=
 			</sources>=0A=
 			<references basedir=3D"..\..\..\nunit">=0A=
 				<includes name=3D"NUnitCore.dll"/>=0A=
 			</references>=0A=
-			<arg value=3D"/r:..\..\lib\System.XML.dll"/>=0A=
-			<arg value=3D"/nowarn:1595"/>=0A=
+			<arg value=3D"/r:.\System.XML.dll"/>=0A=
 		</csc>=0A=
 	</target>=0A=
 =0A=
@@ -26,6 +26,8 @@=0A=
 	</target>=0A=
 =0A=
 	<target name=3D"clean">=0A=
+		<delete file=3D"System.XML.dll" failonerror=3D"false"/>=0A=
 		<delete file=3D"System.XML_test.dll" failonerror=3D"false"/>=0A=
+		<delete file=3D"System.XML_test.pdb" failonerror=3D"false"/>=0A=
 	</target>=0A=
 </project>=0A=
Index: Test/Test.cs=0A=
=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=0A=
RCS file: /mono/mcs/class/System.XML/Test/Test.cs,v=0A=
retrieving revision 1.1=0A=
diff -u -r1.1 Test.cs=0A=
--- Test/Test.cs	2 Sep 2001 18:12:17 -0000	1.1=0A=
+++ Test/Test.cs	10 Feb 2002 19:30:59 -0000=0A=
@@ -34,6 +34,8 @@=0A=
 			int depth,
 			bool isEmptyElement,
 			string name,
+			string prefix,
+			string localName,
 			string value,
 			int attributeCount)
 		{
@@ -44,11 +46,44 @@=0A=
 			Assert(xmlReader.NodeType =3D=3D nodeType);
 			Assert(xmlReader.Depth =3D=3D depth);
 			Assert(xmlReader.IsEmptyElement =3D=3D isEmptyElement);
-			Assert(xmlReader.Name =3D=3D name);
+
+			Assert(
+				String.Format(
+					"name was {0}, expected {1}",
+					xmlReader.Name,
+					name),
+				xmlReader.Name =3D=3D name);
+
+			Assert(
+				String.Format(
+					"prefix was {0}, expected {1}",
+					xmlReader.Prefix,
+					prefix),
+				xmlReader.Prefix =3D=3D prefix);
+
+			Assert(
+				String.Format(
+					"localName was {0}, expected {1}",
+					xmlReader.LocalName,
+					localName),
+				xmlReader.LocalName =3D=3D localName);
+
 			Assert(xmlReader.HasValue =3D=3D (value !=3D String.Empty));
 			Assert(xmlReader.Value =3D=3D value);
-			Assert(xmlReader.HasAttributes =3D=3D (attributeCount > 0));
-			Assert(xmlReader.AttributeCount =3D=3D attributeCount);
+
+			Assert(
+				String.Format(
+					"hasAttributes was {0}, expected {1}",
+					xmlReader.HasAttributes,
+					(attributeCount > 0)),
+				xmlReader.HasAttributes =3D=3D (attributeCount > 0));
+
+			Assert(
+				String.Format(
+					"attributeCount was {0}, expected {1}",
+					xmlReader.AttributeCount,
+					attributeCount),
+				xmlReader.AttributeCount =3D=3D attributeCount);
 		}
=20
 		private void AssertAttribute(
@@ -86,6 +121,8 @@=0A=
 				0, // depth
 				true, // isEmptyElement
 				"foo", // name
+				String.Empty, // prefix
+				"foo", // localName
 				String.Empty, // value
 				0 // attributeCount
 			);
@@ -107,6 +144,8 @@=0A=
 				0, //depth
 				true, // isEmptyElement
 				"foo", // name
+				String.Empty, // prefix
+				"foo", // localName
 				String.Empty, // value
 				0 // attributeCount
 			);
@@ -128,6 +167,8 @@=0A=
 				0, //depth
 				false, // isEmptyElement
 				"foo", // name
+				String.Empty, // prefix
+				"foo", // localName
 				String.Empty, // value
 				0 // attributeCount
 			);
@@ -138,6 +179,8 @@=0A=
 				0, //depth
 				false, // isEmptyElement
 				"foo", // name
+				String.Empty, // prefix
+				"foo", // localName
 				String.Empty, // value
 				0 // attributeCount
 			);
@@ -159,6 +202,8 @@=0A=
 				0, //depth
 				false, // isEmptyElement
 				"foo", // name
+				String.Empty, // prefix
+				"foo", // localName
 				String.Empty, // value
 				0 // attributeCount
 			);
@@ -169,6 +214,8 @@=0A=
 				0, //depth
 				false, // isEmptyElement
 				"foo", // name
+				String.Empty, // prefix
+				"foo", // localName
 				String.Empty, // value
 				0 // attributeCount
 			);
@@ -190,6 +237,8 @@=0A=
 				0, //depth
 				false, // isEmptyElement
 				"foo", // name
+				String.Empty, // prefix
+				"foo", // localName
 				String.Empty, // value
 				0 // attributeCount
 			);
@@ -200,6 +249,8 @@=0A=
 				1, //depth
 				true, // isEmptyElement
 				"bar", // name
+				String.Empty, // prefix
+				"bar", // localName
 				String.Empty, // value
 				0 // attributeCount
 			);
@@ -210,6 +261,8 @@=0A=
 				0, //depth
 				false, // isEmptyElement
 				"foo", // name
+				String.Empty, // prefix
+				"foo", // localName
 				String.Empty, // value
 				0 // attributeCount
 			);
@@ -231,6 +284,8 @@=0A=
 				0, //depth
 				false, // isEmptyElement
 				"foo", // name
+				String.Empty, // prefix
+				"foo", // localName
 				String.Empty, // value
 				0 // attributeCount
 			);
@@ -241,6 +296,8 @@=0A=
 				1, //depth
 				false, // isEmptyElement
 				String.Empty, // name
+				String.Empty, // prefix
+				String.Empty, // localName
 				"bar", // value
 				0 // attributeCount
 			);
@@ -251,6 +308,8 @@=0A=
 				0, //depth
 				false, // isEmptyElement
 				"foo", // name
+				String.Empty, // prefix
+				"foo", // localName
 				String.Empty, // value
 				0 // attributeCount
 			);
@@ -272,6 +331,8 @@=0A=
 				0, //depth
 				true, // isEmptyElement
 				"foo", // name
+				String.Empty, // prefix
+				"foo", // localName
 				String.Empty, // value
 				1 // attributeCount
 			);
@@ -299,6 +360,8 @@=0A=
 				0, //depth
 				false, // isEmptyElement
 				"foo", // name
+				String.Empty, // prefix
+				"foo", // localName
 				String.Empty, // value
 				1 // attributeCount
 			);
@@ -315,6 +378,8 @@=0A=
 				0, //depth
 				false, // isEmptyElement
 				"foo", // name
+				String.Empty, // prefix
+				"foo", // localName
 				String.Empty, // value
 				0 // attributeCount
 			);
@@ -336,6 +401,8 @@=0A=
 				0, //depth
 				true, // isEmptyElement
 				"foo", // name
+				String.Empty, // prefix
+				"foo", // localName
 				String.Empty, // value
 				2 // attributeCount
 			);
@@ -369,6 +436,8 @@=0A=
 				0, //depth
 				false, // isEmptyElement
 				"foo", // name
+				String.Empty, // prefix
+				"foo", // localName
 				"bar", // value
 				0 // attributeCount
 			);
@@ -379,6 +448,8 @@=0A=
 				0, //depth
 				true, // isEmptyElement
 				"baz", // name
+				String.Empty, // prefix
+				"baz", // localName
 				String.Empty, // value
 				0 // attributeCount
 			);
@@ -400,6 +471,8 @@=0A=
 				0, //depth
 				false, // isEmptyElement
 				String.Empty, // name
+				String.Empty, // prefix
+				String.Empty, // localName
 				"foo", // value
 				0 // attributeCount
 			);
@@ -410,6 +483,8 @@=0A=
 				0, //depth
 				true, // isEmptyElement
 				"bar", // name
+				String.Empty, // prefix
+				"bar", // localName
 				String.Empty, // value
 				0 // attributeCount
 			);
@@ -431,6 +506,8 @@=0A=
 				0, //depth
 				false, // isEmptyElement
 				"foo", // name
+				String.Empty, // prefix
+				"foo", // localName
 				String.Empty, // value
 				0 // attributeCount
 			);
@@ -441,6 +518,8 @@=0A=
 				1, //depth
 				false, // isEmptyElement
 				String.Empty, // name
+				String.Empty, // prefix
+				String.Empty, // localName
 				"<>&'\"", // value
 				0 // attributeCount
 			);
@@ -451,6 +530,8 @@=0A=
 				0, //depth
 				false, // isEmptyElement
 				"foo", // name
+				String.Empty, // prefix
+				"foo", // localName
 				String.Empty, // value
 				0 // attributeCount
 			);
@@ -472,6 +553,8 @@=0A=
 				0, //depth
 				false, // isEmptyElement
 				"foo", // name
+				String.Empty, // prefix
+				"foo", // localName
 				String.Empty, // value
 				0 // attributeCount
 			);
@@ -482,6 +565,8 @@=0A=
 				1, //depth
 				false, // isEmptyElement
 				"bar", // name
+				String.Empty, // prefix
+				"bar", // localName
 				String.Empty, // value
 				0 // attributeCount
 			);
@@ -492,6 +577,8 @@=0A=
 				0, //depth
 				false, // isEmptyElement
 				"foo", // name
+				String.Empty, // prefix
+				"foo", // localName
 				String.Empty, // value
 				0 // attributeCount
 			);
@@ -513,6 +600,8 @@=0A=
 				0, //depth
 				false, // isEmptyElement
 				"foo", // name
+				String.Empty, // prefix
+				"foo", // localName
 				String.Empty, // value
 				0 // attributeCount
 			);
@@ -523,6 +612,8 @@=0A=
 				1, //depth
 				false, // isEmptyElement
 				String.Empty, // name
+				String.Empty, // prefix
+				String.Empty, // localName
 				"bar", // value
 				0 // attributeCount
 			);
@@ -533,6 +624,8 @@=0A=
 				1, //depth
 				false, // isEmptyElement
 				"baz", // name
+				String.Empty, // prefix
+				"baz", // localName
 				String.Empty, // value
 				0 // attributeCount
 			);
@@ -543,6 +636,8 @@=0A=
 				1, //depth
 				false, // isEmptyElement
 				String.Empty, // name
+				String.Empty, // prefix
+				String.Empty, // localName
 				"quux", // value
 				0 // attributeCount
 			);
@@ -553,6 +648,8 @@=0A=
 				0, //depth
 				false, // isEmptyElement
 				"foo", // name
+				String.Empty, // prefix
+				"foo", // localName
 				String.Empty, // value
 				0 // attributeCount
 			);
@@ -574,6 +671,8 @@=0A=
 				0, //depth
 				false, // isEmptyElement
 				"foo", // name
+				String.Empty, // prefix
+				"foo", // localName
 				String.Empty, // value
 				0 // attributeCount
 			);
@@ -584,6 +683,8 @@=0A=
 				1, //depth
 				false, // isEmptyElement
 				String.Empty, // name
+				String.Empty, // prefix
+				String.Empty, // localName
 				"FOO", // value
 				0 // attributeCount
 			);
@@ -594,6 +695,8 @@=0A=
 				0, //depth
 				false, // isEmptyElement
 				"foo", // name
+				String.Empty, // prefix
+				"foo", // localName
 				String.Empty, // value
 				0 // attributeCount
 			);
@@ -615,6 +718,8 @@=0A=
 				0, //depth
 				true, // isEmptyElement
 				"foo", // name
+				String.Empty, // prefix
+				"foo", // localName
 				String.Empty, // value
 				1 // attributeCount
 			);
@@ -642,6 +747,8 @@=0A=
 				0, //depth
 				true, // isEmptyElement
 				"foo", // name
+				String.Empty, // prefix
+				"foo", // localName
 				String.Empty, // value
 				1 // attributeCount
 			);
@@ -669,6 +776,8 @@=0A=
 				0, //depth
 				true, // isEmptyElement
 				"foo", // name
+				String.Empty, // prefix
+				"foo", // localName
 				String.Empty, // value
 				1 // attributeCount
 			);
@@ -696,6 +805,8 @@=0A=
 				0, //depth
 				false, // isEmptyElement
 				"foo", // name
+				String.Empty, // prefix
+				"foo", // localName
 				String.Empty, // value
 				0 // attributeCount
 			);
@@ -706,6 +817,8 @@=0A=
 				1, //depth
 				false, // isEmptyElement
 				String.Empty, // name
+				String.Empty, // prefix
+				String.Empty, // localName
 				"<>&", // value
 				0 // attributeCount
 			);
@@ -716,6 +829,31 @@=0A=
 				0, //depth
 				false, // isEmptyElement
 				"foo", // name
+				String.Empty, // prefix
+				"foo", // localName
+				String.Empty, // value
+				0 // attributeCount
+			);
+
+			AssertEndDocument(xmlReader);
+		}
+
+		public void TestEmptyElementInNamespace()
+		{
+			string xml =3D @"<foo:bar />";
+			XmlReader xmlReader =3D
+				new XmlTextReader(new StringReader(xml));
+
+			AssertStartDocument(xmlReader);
+
+			AssertNode(
+				xmlReader, // xmlReader
+				XmlNodeType.Element, // nodeType
+				0, // depth
+				true, // isEmptyElement
+				"foo:bar", // name
+				"foo", // prefix
+				"bar", // localName
 				String.Empty, // value
 				0 // attributeCount
 			);

------=_NextPart_000_000A_01C1B225.EA6A1780--