소스 검색

Add System.XML

svn path=/trunk/mcs/; revision=170
Miguel de Icaza 24 년 전
부모
커밋
405dc3ea6c

+ 40 - 0
mcs/class/System.XML/System.Xml/Driver.cs

@@ -0,0 +1,40 @@
+// -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+//
+// Driver.cs
+//
+// Author:
+//   Jason Diamond ([email protected])
+//
+// (C) 2001 Jason Diamond  http://injektilo.org/
+//
+
+using System;
+using System.Xml;
+
+public class Driver
+{
+	public static void Main(string[] args)
+	{
+		XmlReader xmlReader = null;
+
+		if (args.Length < 1)
+		{
+			xmlReader = new XmlTextReader(Console.In);
+		}
+		else
+		{
+			xmlReader = new XmlTextReader(args[0]);
+		}
+
+		while (xmlReader.Read())
+		{
+			Console.WriteLine("NodeType = {0}", xmlReader.NodeType);
+			Console.WriteLine("  Name = {0}", xmlReader.Name);
+			Console.WriteLine("  IsEmptyElement = {0}", xmlReader.IsEmptyElement);
+			Console.WriteLine("  HasAttributes = {0}", xmlReader.HasAttributes);
+			Console.WriteLine("  AttributeCount = {0}", xmlReader.AttributeCount);
+			Console.WriteLine("  HasValue = {0}", xmlReader.HasValue);
+			Console.WriteLine("  Value = {0}", xmlReader.Value);
+		}
+	}
+}

+ 21 - 0
mcs/class/System.XML/System.Xml/ReadState.cs

@@ -0,0 +1,21 @@
+// -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+//
+// System.Xml.ReadState.cs
+//
+// Author:
+//   Jason Diamond ([email protected])
+//
+// (C) 2001 Jason Diamond  http://injektilo.org/
+//
+
+namespace System.Xml
+{
+	public enum ReadState
+	{
+		Closed,
+		EndOfFile,
+		Error,
+		Initial,
+		Interactive
+	}
+}

+ 817 - 0
mcs/class/System.XML/System.Xml/Test.cs

@@ -0,0 +1,817 @@
+// -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+//
+// System.Xml.Test.cs
+//
+// Author:
+//   Jason Diamond ([email protected])
+//
+// (C) 2001 Jason Diamond  http://injektilo.org/
+//
+
+using System;
+using System.Diagnostics;
+using System.IO;
+
+using NUnit.Framework;
+
+namespace System.Xml
+{
+	public class Test : TestCase
+	{
+		public Test(string name) : base(name) { }
+
+		private void AssertStartDocument(XmlReader xmlReader)
+		{
+			Assert(xmlReader.ReadState == ReadState.Initial);
+			Assert(xmlReader.NodeType == XmlNodeType.None);
+			Assert(!xmlReader.EOF);
+		}
+
+		private void AssertNode(
+			XmlReader xmlReader,
+			XmlNodeType nodeType,
+			bool isEmptyElement,
+			string name,
+			string value,
+			int attributeCount)
+		{
+			Assert(xmlReader.Read());
+			Assert(xmlReader.ReadState == ReadState.Interactive);
+			Assert(!xmlReader.EOF);
+
+			Assert(xmlReader.NodeType == nodeType);
+			Assert(xmlReader.IsEmptyElement == isEmptyElement);
+			Assert(xmlReader.Name == name);
+			Assert(xmlReader.HasValue == (value != String.Empty));
+			Assert(xmlReader.Value == value);
+			Assert(xmlReader.HasAttributes == (attributeCount > 0));
+			Assert(xmlReader.AttributeCount == attributeCount);
+		}
+
+		private void AssertAttribute(
+			XmlReader xmlReader,
+			string name,
+			string value)
+		{
+			Assert(xmlReader[name] == value);
+			Assert(xmlReader.GetAttribute(name) == value);
+		}
+
+		private void AssertEndDocument(XmlReader xmlReader)
+		{
+			Assert(!xmlReader.Read());
+			Assert(xmlReader.NodeType == XmlNodeType.None);
+			Assert(xmlReader.ReadState == ReadState.EndOfFile);
+			Assert(xmlReader.EOF);
+
+			xmlReader.Close();
+			Assert(xmlReader.ReadState == ReadState.Closed);
+		}
+
+		public void TestEmptyElement()
+		{
+			string xml = "<foo/>";
+			XmlReader xmlReader =
+				new XmlTextReader(new StringReader(xml));
+
+			AssertStartDocument(xmlReader);
+
+			AssertNode(
+				xmlReader, // xmlReader
+				XmlNodeType.Element, // nodeType
+				true, // isEmptyElement
+				"foo", // name
+				String.Empty, // value
+				0 // attributeCount
+			);
+
+			AssertEndDocument(xmlReader);
+		}
+
+		public void TestEmptyElementWithWhitespace()
+		{
+			string xml = "<foo />";
+			XmlReader xmlReader =
+				new XmlTextReader(new StringReader(xml));
+
+			AssertStartDocument(xmlReader);
+
+			AssertNode(
+				xmlReader, // xmlReader
+				XmlNodeType.Element, // nodeType
+				true, // isEmptyElement
+				"foo", // name
+				String.Empty, // value
+				0 // attributeCount
+			);
+
+			AssertEndDocument(xmlReader);
+		}
+
+		public void TestEmptyElementWithStartAndEndTag()
+		{
+			string xml = "<foo></foo>";
+			XmlReader xmlReader =
+				new XmlTextReader(new StringReader(xml));
+
+			AssertStartDocument(xmlReader);
+
+			AssertNode(
+				xmlReader, // xmlReader
+				XmlNodeType.Element, // nodeType
+				false, // isEmptyElement
+				"foo", // name
+				String.Empty, // value
+				0 // attributeCount
+			);
+
+			AssertNode(
+				xmlReader, // xmlReader
+				XmlNodeType.EndElement, // nodeType
+				false, // isEmptyElement
+				"foo", // name
+				String.Empty, // value
+				0 // attributeCount
+			);
+
+			AssertEndDocument(xmlReader);
+		}
+
+		public void TestEmptyElementWithStartAndEndTagWithWhitespace()
+		{
+			string xml = "<foo ></foo >";
+			XmlReader xmlReader =
+				new XmlTextReader(new StringReader(xml));
+
+			AssertStartDocument(xmlReader);
+
+			AssertNode(
+				xmlReader, // xmlReader
+				XmlNodeType.Element, // nodeType
+				false, // isEmptyElement
+				"foo", // name
+				String.Empty, // value
+				0 // attributeCount
+			);
+
+			AssertNode(
+				xmlReader, // xmlReader
+				XmlNodeType.EndElement, // nodeType
+				false, // isEmptyElement
+				"foo", // name
+				String.Empty, // value
+				0 // attributeCount
+			);
+
+			AssertEndDocument(xmlReader);
+		}
+
+		public void TestNestedEmptyTag()
+		{
+			string xml = "<foo><bar/></foo>";
+			XmlReader xmlReader =
+				new XmlTextReader(new StringReader(xml));
+
+			AssertStartDocument(xmlReader);
+
+			AssertNode(
+				xmlReader, // xmlReader
+				XmlNodeType.Element, // nodeType
+				false, // isEmptyElement
+				"foo", // name
+				String.Empty, // value
+				0 // attributeCount
+			);
+
+			AssertNode(
+				xmlReader, // xmlReader
+				XmlNodeType.Element, // nodeType
+				true, // isEmptyElement
+				"bar", // name
+				String.Empty, // value
+				0 // attributeCount
+			);
+
+			AssertNode(
+				xmlReader, // xmlReader
+				XmlNodeType.EndElement, // nodeType
+				false, // isEmptyElement
+				"foo", // name
+				String.Empty, // value
+				0 // attributeCount
+			);
+
+			AssertEndDocument(xmlReader);
+		}
+
+		public void TestNestedText()
+		{
+			string xml = "<foo>bar</foo>";
+			XmlReader xmlReader =
+				new XmlTextReader(new StringReader(xml));
+
+			AssertStartDocument(xmlReader);
+
+			AssertNode(
+				xmlReader, // xmlReader
+				XmlNodeType.Element, // nodeType
+				false, // isEmptyElement
+				"foo", // name
+				String.Empty, // value
+				0 // attributeCount
+			);
+
+			AssertNode(
+				xmlReader, // xmlReader
+				XmlNodeType.Text, // nodeType
+				false, // isEmptyElement
+				String.Empty, // name
+				"bar", // value
+				0 // attributeCount
+			);
+
+			AssertNode(
+				xmlReader, // xmlReader
+				XmlNodeType.EndElement, // nodeType
+				false, // isEmptyElement
+				"foo", // name
+				String.Empty, // value
+				0 // attributeCount
+			);
+
+			AssertEndDocument(xmlReader);
+		}
+
+		public void TestEmptyElementWithAttribute()
+		{
+			string xml = @"<foo bar=""baz""/>";
+			XmlReader xmlReader =
+				new XmlTextReader(new StringReader(xml));
+
+			AssertStartDocument(xmlReader);
+
+			AssertNode(
+				xmlReader, // xmlReader
+				XmlNodeType.Element, // nodeType
+				true, // isEmptyElement
+				"foo", // name
+				String.Empty, // value
+				1 // attributeCount
+			);
+
+			AssertAttribute(
+				xmlReader, // xmlReader
+				"bar", // name
+				"baz" // value
+			);
+
+			AssertEndDocument(xmlReader);
+		}
+
+		public void TestStartAndEndTagWithAttribute()
+		{
+			string xml = @"<foo bar='baz'></foo>";
+			XmlReader xmlReader =
+				new XmlTextReader(new StringReader(xml));
+
+			AssertStartDocument(xmlReader);
+
+			AssertNode(
+				xmlReader, // xmlReader
+				XmlNodeType.Element, // nodeType
+				false, // isEmptyElement
+				"foo", // name
+				String.Empty, // value
+				1 // attributeCount
+			);
+
+			AssertAttribute(
+				xmlReader, // xmlReader
+				"bar", // name
+				"baz" // value
+			);
+
+			AssertNode(
+				xmlReader, // xmlReader
+				XmlNodeType.EndElement, // nodeType
+				false, // isEmptyElement
+				"foo", // name
+				String.Empty, // value
+				0 // attributeCount
+			);
+
+			AssertEndDocument(xmlReader);
+		}
+
+		public void TestEmptyElementWithTwoAttributes()
+		{
+			string xml = @"<foo bar=""baz"" quux='quuux'/>";
+			XmlReader xmlReader =
+				new XmlTextReader(new StringReader(xml));
+
+			AssertStartDocument(xmlReader);
+
+			AssertNode(
+				xmlReader, // xmlReader
+				XmlNodeType.Element, // nodeType
+				true, // isEmptyElement
+				"foo", // name
+				String.Empty, // value
+				2 // attributeCount
+			);
+
+			AssertAttribute(
+				xmlReader, // xmlReader
+				"bar", // name
+				"baz" // value
+			);
+
+			AssertAttribute(
+				xmlReader, // xmlReader
+				"quux", // name
+				"quuux" // value
+			);
+
+			AssertEndDocument(xmlReader);
+		}
+
+		public void TestProcessingInstructionBeforeDocumentElement()
+		{
+			string xml = "<?foo bar?><baz/>";
+			XmlReader xmlReader =
+				new XmlTextReader(new StringReader(xml));
+
+			AssertStartDocument(xmlReader);
+
+			AssertNode(
+				xmlReader, // xmlReader
+				XmlNodeType.ProcessingInstruction, // nodeType
+				false, // isEmptyElement
+				"foo", // name
+				"bar", // value
+				0 // attributeCount
+			);
+
+			AssertNode(
+				xmlReader, // xmlReader
+				XmlNodeType.Element, // nodeType
+				true, // isEmptyElement
+				"baz", // name
+				String.Empty, // value
+				0 // attributeCount
+			);
+
+			AssertEndDocument(xmlReader);
+		}
+
+		public void TestCommentBeforeDocumentElement()
+		{
+			string xml = "<!--foo--><bar/>";
+			XmlReader xmlReader =
+				new XmlTextReader(new StringReader(xml));
+
+			AssertStartDocument(xmlReader);
+
+			AssertNode(
+				xmlReader, // xmlReader
+				XmlNodeType.Comment, // nodeType
+				false, // isEmptyElement
+				String.Empty, // name
+				"foo", // value
+				0 // attributeCount
+			);
+
+			AssertNode(
+				xmlReader, // xmlReader
+				XmlNodeType.Element, // nodeType
+				true, // isEmptyElement
+				"bar", // name
+				String.Empty, // value
+				0 // attributeCount
+			);
+
+			AssertEndDocument(xmlReader);
+		}
+
+// The following is #if'ed out because it's specific to the Mono
+// implementation and won't compile when testing Microsoft's code.
+// Feel free to turn it on if you want to test Mono's name tables.
+
+#if false
+
+		public void TestIsFirstNameChar()
+		{
+			for (int ch = 0; ch <= 0xFFFF; ++ch)
+			{
+				Assert(
+					XmlChar.IsFirstNameChar(ch) ==
+						IsFirstNameChar(ch));
+			}
+		}
+
+		public void TestIsNameChar()
+		{
+			for (int ch = 0; ch <= 0xFFFF; ++ch)
+			{
+				Assert(
+					XmlChar.IsNameChar(ch) ==
+						IsNameChar(ch));
+			}
+		}
+
+		private static bool IsFirstNameChar(int ch)
+		{
+			return
+				IsLetter(ch) ||
+				(ch == '_') ||
+				(ch == ':');
+		}
+
+		private static bool IsNameChar(int ch)
+		{
+			return
+				IsLetter(ch) ||
+				IsDigit(ch) ||
+				(ch == '.') ||
+				(ch == '-') ||
+				(ch == '_') ||
+				(ch == ':') ||
+				IsCombiningChar(ch) ||
+				IsExtender(ch);
+		}
+
+		private static bool IsLetter(int ch)
+		{
+			return
+				IsBaseChar(ch) ||
+				IsIdeographic(ch);
+		}
+
+		private static bool IsBaseChar(int ch)
+		{
+			return
+				(ch >= 0x0041 && ch <= 0x005A) ||
+				(ch >= 0x0061 && ch <= 0x007A) ||
+				(ch >= 0x00C0 && ch <= 0x00D6) ||
+				(ch >= 0x00D8 && ch <= 0x00F6) ||
+				(ch >= 0x00F8 && ch <= 0x00FF) ||
+				(ch >= 0x0100 && ch <= 0x0131) ||
+				(ch >= 0x0134 && ch <= 0x013E) ||
+				(ch >= 0x0141 && ch <= 0x0148) ||
+				(ch >= 0x014A && ch <= 0x017E) ||
+				(ch >= 0x0180 && ch <= 0x01C3) ||
+				(ch >= 0x01CD && ch <= 0x01F0) ||
+				(ch >= 0x01F4 && ch <= 0x01F5) ||
+				(ch >= 0x01FA && ch <= 0x0217) ||
+				(ch >= 0x0250 && ch <= 0x02A8) ||
+				(ch >= 0x02BB && ch <= 0x02C1) ||
+				(ch == 0x0386) ||
+				(ch >= 0x0388 && ch <= 0x038A) ||
+				(ch == 0x038C) ||
+				(ch >= 0x038E && ch <= 0x03A1) ||
+				(ch >= 0x03A3 && ch <= 0x03CE) ||
+				(ch >= 0x03D0 && ch <= 0x03D6) ||
+				(ch == 0x03DA) ||
+				(ch == 0x03DC) ||
+				(ch == 0x03DE) ||
+				(ch == 0x03E0) ||
+				(ch >= 0x03E2 && ch <= 0x03F3) ||
+				(ch >= 0x0401 && ch <= 0x040C) ||
+				(ch >= 0x040E && ch <= 0x044F) ||
+				(ch >= 0x0451 && ch <= 0x045C) ||
+				(ch >= 0x045E && ch <= 0x0481) ||
+				(ch >= 0x0490 && ch <= 0x04C4) ||
+				(ch >= 0x04C7 && ch <= 0x04C8) ||
+				(ch >= 0x04CB && ch <= 0x04CC) ||
+				(ch >= 0x04D0 && ch <= 0x04EB) ||
+				(ch >= 0x04EE && ch <= 0x04F5) ||
+				(ch >= 0x04F8 && ch <= 0x04F9) ||
+				(ch >= 0x0531 && ch <= 0x0556) ||
+				(ch == 0x0559) ||
+				(ch >= 0x0561 && ch <= 0x0586) ||
+				(ch >= 0x05D0 && ch <= 0x05EA) ||
+				(ch >= 0x05F0 && ch <= 0x05F2) ||
+				(ch >= 0x0621 && ch <= 0x063A) ||
+				(ch >= 0x0641 && ch <= 0x064A) ||
+				(ch >= 0x0671 && ch <= 0x06B7) ||
+				(ch >= 0x06BA && ch <= 0x06BE) ||
+				(ch >= 0x06C0 && ch <= 0x06CE) ||
+				(ch >= 0x06D0 && ch <= 0x06D3) ||
+				(ch == 0x06D5) ||
+				(ch >= 0x06E5 && ch <= 0x06E6) ||
+				(ch >= 0x0905 && ch <= 0x0939) ||
+				(ch == 0x093D) ||
+				(ch >= 0x0958 && ch <= 0x0961) ||
+				(ch >= 0x0985 && ch <= 0x098C) ||
+				(ch >= 0x098F && ch <= 0x0990) ||
+				(ch >= 0x0993 && ch <= 0x09A8) ||
+				(ch >= 0x09AA && ch <= 0x09B0) ||
+				(ch == 0x09B2) ||
+				(ch >= 0x09B6 && ch <= 0x09B9) ||
+				(ch >= 0x09DC && ch <= 0x09DD) ||
+				(ch >= 0x09DF && ch <= 0x09E1) ||
+				(ch >= 0x09F0 && ch <= 0x09F1) ||
+				(ch >= 0x0A05 && ch <= 0x0A0A) ||
+				(ch >= 0x0A0F && ch <= 0x0A10) ||
+				(ch >= 0x0A13 && ch <= 0x0A28) ||
+				(ch >= 0x0A2A && ch <= 0x0A30) ||
+				(ch >= 0x0A32 && ch <= 0x0A33) ||
+				(ch >= 0x0A35 && ch <= 0x0A36) ||
+				(ch >= 0x0A38 && ch <= 0x0A39) ||
+				(ch >= 0x0A59 && ch <= 0x0A5C) ||
+				(ch == 0x0A5E) ||
+				(ch >= 0x0A72 && ch <= 0x0A74) ||
+				(ch >= 0x0A85 && ch <= 0x0A8B) ||
+				(ch == 0x0A8D) ||
+				(ch >= 0x0A8F && ch <= 0x0A91) ||
+				(ch >= 0x0A93 && ch <= 0x0AA8) ||
+				(ch >= 0x0AAA && ch <= 0x0AB0) ||
+				(ch >= 0x0AB2 && ch <= 0x0AB3) ||
+				(ch >= 0x0AB5 && ch <= 0x0AB9) ||
+				(ch == 0x0ABD) ||
+				(ch == 0x0AE0) ||
+				(ch >= 0x0B05 && ch <= 0x0B0C) ||
+				(ch >= 0x0B0F && ch <= 0x0B10) ||
+				(ch >= 0x0B13 && ch <= 0x0B28) ||
+				(ch >= 0x0B2A && ch <= 0x0B30) ||
+				(ch >= 0x0B32 && ch <= 0x0B33) ||
+				(ch >= 0x0B36 && ch <= 0x0B39) ||
+				(ch == 0x0B3D) ||
+				(ch >= 0x0B5C && ch <= 0x0B5D) ||
+				(ch >= 0x0B5F && ch <= 0x0B61) ||
+				(ch >= 0x0B85 && ch <= 0x0B8A) ||
+				(ch >= 0x0B8E && ch <= 0x0B90) ||
+				(ch >= 0x0B92 && ch <= 0x0B95) ||
+				(ch >= 0x0B99 && ch <= 0x0B9A) ||
+				(ch == 0x0B9C) ||
+				(ch >= 0x0B9E && ch <= 0x0B9F) ||
+				(ch >= 0x0BA3 && ch <= 0x0BA4) ||
+				(ch >= 0x0BA8 && ch <= 0x0BAA) ||
+				(ch >= 0x0BAE && ch <= 0x0BB5) ||
+				(ch >= 0x0BB7 && ch <= 0x0BB9) ||
+				(ch >= 0x0C05 && ch <= 0x0C0C) ||
+				(ch >= 0x0C0E && ch <= 0x0C10) ||
+				(ch >= 0x0C12 && ch <= 0x0C28) ||
+				(ch >= 0x0C2A && ch <= 0x0C33) ||
+				(ch >= 0x0C35 && ch <= 0x0C39) ||
+				(ch >= 0x0C60 && ch <= 0x0C61) ||
+				(ch >= 0x0C85 && ch <= 0x0C8C) ||
+				(ch >= 0x0C8E && ch <= 0x0C90) ||
+				(ch >= 0x0C92 && ch <= 0x0CA8) ||
+				(ch >= 0x0CAA && ch <= 0x0CB3) ||
+				(ch >= 0x0CB5 && ch <= 0x0CB9) ||
+				(ch == 0x0CDE) ||
+				(ch >= 0x0CE0 && ch <= 0x0CE1) ||
+				(ch >= 0x0D05 && ch <= 0x0D0C) ||
+				(ch >= 0x0D0E && ch <= 0x0D10) ||
+				(ch >= 0x0D12 && ch <= 0x0D28) ||
+				(ch >= 0x0D2A && ch <= 0x0D39) ||
+				(ch >= 0x0D60 && ch <= 0x0D61) ||
+				(ch >= 0x0E01 && ch <= 0x0E2E) ||
+				(ch == 0x0E30) ||
+				(ch >= 0x0E32 && ch <= 0x0E33) ||
+				(ch >= 0x0E40 && ch <= 0x0E45) ||
+				(ch >= 0x0E81 && ch <= 0x0E82) ||
+				(ch == 0x0E84) ||
+				(ch >= 0x0E87 && ch <= 0x0E88) ||
+				(ch == 0x0E8A) ||
+				(ch == 0x0E8D) ||
+				(ch >= 0x0E94 && ch <= 0x0E97) ||
+				(ch >= 0x0E99 && ch <= 0x0E9F) ||
+				(ch >= 0x0EA1 && ch <= 0x0EA3) ||
+				(ch == 0x0EA5) ||
+				(ch == 0x0EA7) ||
+				(ch >= 0x0EAA && ch <= 0x0EAB) ||
+				(ch >= 0x0EAD && ch <= 0x0EAE) ||
+				(ch == 0x0EB0) ||
+				(ch >= 0x0EB2 && ch <= 0x0EB3) ||
+				(ch == 0x0EBD) ||
+				(ch >= 0x0EC0 && ch <= 0x0EC4) ||
+				(ch >= 0x0F40 && ch <= 0x0F47) ||
+				(ch >= 0x0F49 && ch <= 0x0F69) ||
+				(ch >= 0x10A0 && ch <= 0x10C5) ||
+				(ch >= 0x10D0 && ch <= 0x10F6) ||
+				(ch == 0x1100) ||
+				(ch >= 0x1102 && ch <= 0x1103) ||
+				(ch >= 0x1105 && ch <= 0x1107) ||
+				(ch == 0x1109) ||
+				(ch >= 0x110B && ch <= 0x110C) ||
+				(ch >= 0x110E && ch <= 0x1112) ||
+				(ch == 0x113C) ||
+				(ch == 0x113E) ||
+				(ch == 0x1140) ||
+				(ch == 0x114C) ||
+				(ch == 0x114E) ||
+				(ch == 0x1150) ||
+				(ch >= 0x1154 && ch <= 0x1155) ||
+				(ch == 0x1159) ||
+				(ch >= 0x115F && ch <= 0x1161) ||
+				(ch == 0x1163) ||
+				(ch == 0x1165) ||
+				(ch == 0x1167) ||
+				(ch == 0x1169) ||
+				(ch >= 0x116D && ch <= 0x116E) ||
+				(ch >= 0x1172 && ch <= 0x1173) ||
+				(ch == 0x1175) ||
+				(ch == 0x119E) ||
+				(ch == 0x11A8) ||
+				(ch == 0x11AB) ||
+				(ch >= 0x11AE && ch <= 0x11AF) ||
+				(ch >= 0x11B7 && ch <= 0x11B8) ||
+				(ch == 0x11BA) ||
+				(ch >= 0x11BC && ch <= 0x11C2) ||
+				(ch == 0x11EB) ||
+				(ch == 0x11F0) ||
+				(ch == 0x11F9) ||
+				(ch >= 0x1E00 && ch <= 0x1E9B) ||
+				(ch >= 0x1EA0 && ch <= 0x1EF9) ||
+				(ch >= 0x1F00 && ch <= 0x1F15) ||
+				(ch >= 0x1F18 && ch <= 0x1F1D) ||
+				(ch >= 0x1F20 && ch <= 0x1F45) ||
+				(ch >= 0x1F48 && ch <= 0x1F4D) ||
+				(ch >= 0x1F50 && ch <= 0x1F57) ||
+				(ch == 0x1F59) ||
+				(ch == 0x1F5B) ||
+				(ch == 0x1F5D) ||
+				(ch >= 0x1F5F && ch <= 0x1F7D) ||
+				(ch >= 0x1F80 && ch <= 0x1FB4) ||
+				(ch >= 0x1FB6 && ch <= 0x1FBC) ||
+				(ch == 0x1FBE) ||
+				(ch >= 0x1FC2 && ch <= 0x1FC4) ||
+				(ch >= 0x1FC6 && ch <= 0x1FCC) ||
+				(ch >= 0x1FD0 && ch <= 0x1FD3) ||
+				(ch >= 0x1FD6 && ch <= 0x1FDB) ||
+				(ch >= 0x1FE0 && ch <= 0x1FEC) ||
+				(ch >= 0x1FF2 && ch <= 0x1FF4) ||
+				(ch >= 0x1FF6 && ch <= 0x1FFC) ||
+				(ch == 0x2126) ||
+				(ch >= 0x212A && ch <= 0x212B) ||
+				(ch == 0x212E) ||
+				(ch >= 0x2180 && ch <= 0x2182) ||
+				(ch >= 0x3041 && ch <= 0x3094) ||
+				(ch >= 0x30A1 && ch <= 0x30FA) ||
+				(ch >= 0x3105 && ch <= 0x312C) ||
+				(ch >= 0xAC00 && ch <= 0xD7A3);
+		}
+
+		private static bool IsIdeographic(int ch)
+		{
+			return
+				(ch >= 0x4E00 && ch <= 0x9FA5) ||
+				(ch == 0x3007) ||
+				(ch >= 0x3021 && ch <= 0x3029);
+		}
+
+		private static bool IsDigit(int ch)
+		{
+			return
+				(ch >= 0x0030 && ch <= 0x0039) ||
+				(ch >= 0x0660 && ch <= 0x0669) ||
+				(ch >= 0x06F0 && ch <= 0x06F9) ||
+				(ch >= 0x0966 && ch <= 0x096F) ||
+				(ch >= 0x09E6 && ch <= 0x09EF) ||
+				(ch >= 0x0A66 && ch <= 0x0A6F) ||
+				(ch >= 0x0AE6 && ch <= 0x0AEF) ||
+				(ch >= 0x0B66 && ch <= 0x0B6F) ||
+				(ch >= 0x0BE7 && ch <= 0x0BEF) ||
+				(ch >= 0x0C66 && ch <= 0x0C6F) ||
+				(ch >= 0x0CE6 && ch <= 0x0CEF) ||
+				(ch >= 0x0D66 && ch <= 0x0D6F) ||
+				(ch >= 0x0E50 && ch <= 0x0E59) ||
+				(ch >= 0x0ED0 && ch <= 0x0ED9) ||
+				(ch >= 0x0F20 && ch <= 0x0F29);
+		}
+
+		private static bool IsCombiningChar(int ch)
+		{
+			return
+				(ch >= 0x0300 && ch <= 0x0345) ||
+				(ch >= 0x0360 && ch <= 0x0361) ||
+				(ch >= 0x0483 && ch <= 0x0486) ||
+				(ch >= 0x0591 && ch <= 0x05A1) ||
+				(ch >= 0x05A3 && ch <= 0x05B9) ||
+				(ch >= 0x05BB && ch <= 0x05BD) ||
+				(ch == 0x05BF) ||
+				(ch >= 0x05C1 && ch <= 0x05C2) ||
+				(ch == 0x05C4) ||
+				(ch >= 0x064B && ch <= 0x0652) ||
+				(ch == 0x0670) ||
+				(ch >= 0x06D6 && ch <= 0x06DC) ||
+				(ch >= 0x06DD && ch <= 0x06DF) ||
+				(ch >= 0x06E0 && ch <= 0x06E4) ||
+				(ch >= 0x06E7 && ch <= 0x06E8) ||
+				(ch >= 0x06EA && ch <= 0x06ED) ||
+				(ch >= 0x0901 && ch <= 0x0903) ||
+				(ch == 0x093C) ||
+				(ch >= 0x093E && ch <= 0x094C) ||
+				(ch == 0x094D) ||
+				(ch >= 0x0951 && ch <= 0x0954) ||
+				(ch >= 0x0962 && ch <= 0x0963) ||
+				(ch >= 0x0981 && ch <= 0x0983) ||
+				(ch == 0x09BC) ||
+				(ch == 0x09BE) ||
+				(ch == 0x09BF) ||
+				(ch >= 0x09C0 && ch <= 0x09C4) ||
+				(ch >= 0x09C7 && ch <= 0x09C8) ||
+				(ch >= 0x09CB && ch <= 0x09CD) ||
+				(ch == 0x09D7) ||
+				(ch >= 0x09E2 && ch <= 0x09E3) ||
+				(ch == 0x0A02) ||
+				(ch == 0x0A3C) ||
+				(ch == 0x0A3E) ||
+				(ch == 0x0A3F) ||
+				(ch >= 0x0A40 && ch <= 0x0A42) ||
+				(ch >= 0x0A47 && ch <= 0x0A48) ||
+				(ch >= 0x0A4B && ch <= 0x0A4D) ||
+				(ch >= 0x0A70 && ch <= 0x0A71) ||
+				(ch >= 0x0A81 && ch <= 0x0A83) ||
+				(ch == 0x0ABC) ||
+				(ch >= 0x0ABE && ch <= 0x0AC5) ||
+				(ch >= 0x0AC7 && ch <= 0x0AC9) ||
+				(ch >= 0x0ACB && ch <= 0x0ACD) ||
+				(ch >= 0x0B01 && ch <= 0x0B03) ||
+				(ch == 0x0B3C) ||
+				(ch >= 0x0B3E && ch <= 0x0B43) ||
+				(ch >= 0x0B47 && ch <= 0x0B48) ||
+				(ch >= 0x0B4B && ch <= 0x0B4D) ||
+				(ch >= 0x0B56 && ch <= 0x0B57) ||
+				(ch >= 0x0B82 && ch <= 0x0B83) ||
+				(ch >= 0x0BBE && ch <= 0x0BC2) ||
+				(ch >= 0x0BC6 && ch <= 0x0BC8) ||
+				(ch >= 0x0BCA && ch <= 0x0BCD) ||
+				(ch == 0x0BD7) ||
+				(ch >= 0x0C01 && ch <= 0x0C03) ||
+				(ch >= 0x0C3E && ch <= 0x0C44) ||
+				(ch >= 0x0C46 && ch <= 0x0C48) ||
+				(ch >= 0x0C4A && ch <= 0x0C4D) ||
+				(ch >= 0x0C55 && ch <= 0x0C56) ||
+				(ch >= 0x0C82 && ch <= 0x0C83) ||
+				(ch >= 0x0CBE && ch <= 0x0CC4) ||
+				(ch >= 0x0CC6 && ch <= 0x0CC8) ||
+				(ch >= 0x0CCA && ch <= 0x0CCD) ||
+				(ch >= 0x0CD5 && ch <= 0x0CD6) ||
+				(ch >= 0x0D02 && ch <= 0x0D03) ||
+				(ch >= 0x0D3E && ch <= 0x0D43) ||
+				(ch >= 0x0D46 && ch <= 0x0D48) ||
+				(ch >= 0x0D4A && ch <= 0x0D4D) ||
+				(ch == 0x0D57) ||
+				(ch == 0x0E31) ||
+				(ch >= 0x0E34 && ch <= 0x0E3A) ||
+				(ch >= 0x0E47 && ch <= 0x0E4E) ||
+				(ch == 0x0EB1) ||
+				(ch >= 0x0EB4 && ch <= 0x0EB9) ||
+				(ch >= 0x0EBB && ch <= 0x0EBC) ||
+				(ch >= 0x0EC8 && ch <= 0x0ECD) ||
+				(ch >= 0x0F18 && ch <= 0x0F19) ||
+				(ch == 0x0F35) ||
+				(ch == 0x0F37) ||
+				(ch == 0x0F39) ||
+				(ch == 0x0F3E) ||
+				(ch == 0x0F3F) ||
+				(ch >= 0x0F71 && ch <= 0x0F84) ||
+				(ch >= 0x0F86 && ch <= 0x0F8B) ||
+				(ch >= 0x0F90 && ch <= 0x0F95) ||
+				(ch == 0x0F97) ||
+				(ch >= 0x0F99 && ch <= 0x0FAD) ||
+				(ch >= 0x0FB1 && ch <= 0x0FB7) ||
+				(ch == 0x0FB9) ||
+				(ch >= 0x20D0 && ch <= 0x20DC) ||
+				(ch == 0x20E1) ||
+				(ch >= 0x302A && ch <= 0x302F) ||
+				(ch == 0x3099) ||
+				(ch == 0x309A);
+		}
+
+		private static bool IsExtender(int ch)
+		{
+			return
+				(ch == 0x00B7) ||
+				(ch == 0x02D0) ||
+				(ch == 0x02D1) ||
+				(ch == 0x0387) ||
+				(ch == 0x0640) ||
+				(ch == 0x0E46) ||
+				(ch == 0x0EC6) ||
+				(ch == 0x3005) ||
+				(ch >= 0x3031 && ch <= 0x3035) ||
+				(ch >= 0x309D && ch <= 0x309E) ||
+				(ch >= 0x30FC && ch <= 0x30FE);
+		}
+
+#endif
+
+		public void TestIsName()
+		{
+			Assert(XmlReader.IsName("foo"));
+			Assert(!XmlReader.IsName("1foo"));
+			Assert(!XmlReader.IsName(" foo"));
+		}
+
+		public void TestIsNameToken()
+		{
+			Assert(XmlReader.IsNameToken("foo"));
+			Assert(XmlReader.IsNameToken("1foo"));
+			Assert(!XmlReader.IsNameToken(" foo"));
+		}
+	}
+}

+ 202 - 0
mcs/class/System.XML/System.Xml/XmlChar.cs

@@ -0,0 +1,202 @@
+// -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+//
+// System.Xml.XmlChar.cs
+//
+// Author:
+//   Jason Diamond ([email protected])
+//
+// (C) 2001 Jason Diamond  http://injektilo.org/
+//
+
+using System;
+
+namespace System.Xml
+{
+	internal class XmlChar
+	{
+		internal static bool IsWhitespace(int ch)
+		{
+			return ch == 0x20 || ch == 0x9 || ch == 0xD || ch == 0xA;
+		}
+
+		internal static bool IsFirstNameChar(int ch)
+		{
+			bool result = false;
+
+			if (ch >= 0 && ch <= 0xFFFF)
+			{
+				result = (nameBitmap[(firstNamePages[ch >> 8] << 3) + ((ch & 0xFF) >> 5)] & (1 << (ch & 0x1F))) != 0;
+			}
+
+			return result;
+		}
+
+		internal static bool IsNameChar(int ch)
+		{
+			bool result = false;
+
+			if (ch >= 0 && ch <= 0xFFFF)
+			{
+				result = (nameBitmap[(namePages[ch >> 8] << 3) + ((ch & 0xFF) >> 5)] & (1 << (ch & 0x1F))) != 0;
+			}
+
+			return result;
+		}
+
+		private static byte[] firstNamePages =
+		{
+			0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x00,
+			0x00, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
+			0x10, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+			0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x12, 0x13,
+			0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+			0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+			0x15, 0x16, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+			0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+			0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+			0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01,
+			0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+			0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+			0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+			0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+			0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+			0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+			0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+			0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+			0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+			0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x17,
+			0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+			0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01,
+			0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+			0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+			0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+			0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+			0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x18,
+			0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+			0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+			0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+			0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+			0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+		};
+
+		private static byte[] namePages =
+		{
+			0x19, 0x03, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x00,
+			0x00, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25,
+			0x10, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+			0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x12, 0x13,
+			0x26, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+			0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+			0x27, 0x16, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+			0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+			0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+			0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01,
+			0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+			0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+			0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+			0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+			0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+			0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+			0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+			0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+			0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+			0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x17,
+			0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+			0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01,
+			0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+			0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+			0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+			0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+			0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x18,
+			0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+			0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+			0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+			0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+			0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+		};
+
+		private static uint[] nameBitmap =
+		{
+			0x00000000, 0x00000000, 0x00000000, 0x00000000,
+			0x00000000, 0x00000000, 0x00000000, 0x00000000,
+			0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
+			0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
+			0x00000000, 0x04000000, 0x87FFFFFE, 0x07FFFFFE,
+			0x00000000, 0x00000000, 0xFF7FFFFF, 0xFF7FFFFF,
+			0xFFFFFFFF, 0x7FF3FFFF, 0xFFFFFDFE, 0x7FFFFFFF,
+			0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFE00F, 0xFC31FFFF,
+			0x00FFFFFF, 0x00000000, 0xFFFF0000, 0xFFFFFFFF,
+			0xFFFFFFFF, 0xF80001FF, 0x00000003, 0x00000000,
+			0x00000000, 0x00000000, 0x00000000, 0x00000000,
+			0xFFFFD740, 0xFFFFFFFB, 0x547F7FFF, 0x000FFFFD,
+			0xFFFFDFFE, 0xFFFFFFFF, 0xDFFEFFFF, 0xFFFFFFFF,
+			0xFFFF0003, 0xFFFFFFFF, 0xFFFF199F, 0x033FCFFF,
+			0x00000000, 0xFFFE0000, 0x027FFFFF, 0xFFFFFFFE,
+			0x0000007F, 0x00000000, 0xFFFF0000, 0x000707FF,
+			0x00000000, 0x07FFFFFE, 0x000007FE, 0xFFFE0000,
+			0xFFFFFFFF, 0x7CFFFFFF, 0x002F7FFF, 0x00000060,
+			0xFFFFFFE0, 0x23FFFFFF, 0xFF000000, 0x00000003,
+			0xFFF99FE0, 0x03C5FDFF, 0xB0000000, 0x00030003,
+			0xFFF987E0, 0x036DFDFF, 0x5E000000, 0x001C0000,
+			0xFFFBAFE0, 0x23EDFDFF, 0x00000000, 0x00000001,
+			0xFFF99FE0, 0x23CDFDFF, 0xB0000000, 0x00000003,
+			0xD63DC7E0, 0x03BFC718, 0x00000000, 0x00000000,
+			0xFFFDDFE0, 0x03EFFDFF, 0x00000000, 0x00000003,
+			0xFFFDDFE0, 0x03EFFDFF, 0x40000000, 0x00000003,
+			0xFFFDDFE0, 0x03FFFDFF, 0x00000000, 0x00000003,
+			0x00000000, 0x00000000, 0x00000000, 0x00000000,
+			0xFFFFFFFE, 0x000D7FFF, 0x0000003F, 0x00000000,
+			0xFEF02596, 0x200D6CAE, 0x0000001F, 0x00000000,
+			0x00000000, 0x00000000, 0xFFFFFEFF, 0x000003FF,
+			0x00000000, 0x00000000, 0x00000000, 0x00000000,
+			0x00000000, 0x00000000, 0x00000000, 0x00000000,
+			0x00000000, 0xFFFFFFFF, 0xFFFF003F, 0x007FFFFF,
+			0x0007DAED, 0x50000000, 0x82315001, 0x002C62AB,
+			0x40000000, 0xF580C900, 0x00000007, 0x02010800,
+			0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
+			0x0FFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x03FFFFFF,
+			0x3F3FFFFF, 0xFFFFFFFF, 0xAAFF3F3F, 0x3FFFFFFF,
+			0xFFFFFFFF, 0x5FDFFFFF, 0x0FCF1FDC, 0x1FDC1FFF,
+			0x00000000, 0x00004C40, 0x00000000, 0x00000000,
+			0x00000007, 0x00000000, 0x00000000, 0x00000000,
+			0x00000080, 0x000003FE, 0xFFFFFFFE, 0xFFFFFFFF,
+			0x001FFFFF, 0xFFFFFFFE, 0xFFFFFFFF, 0x07FFFFFF,
+			0xFFFFFFE0, 0x00001FFF, 0x00000000, 0x00000000,
+			0x00000000, 0x00000000, 0x00000000, 0x00000000,
+			0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
+			0xFFFFFFFF, 0x0000003F, 0x00000000, 0x00000000,
+			0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
+			0xFFFFFFFF, 0x0000000F, 0x00000000, 0x00000000,
+			0x00000000, 0x07FF6000, 0x87FFFFFE, 0x07FFFFFE,
+			0x00000000, 0x00800000, 0xFF7FFFFF, 0xFF7FFFFF,
+			0x00FFFFFF, 0x00000000, 0xFFFF0000, 0xFFFFFFFF,
+			0xFFFFFFFF, 0xF80001FF, 0x00030003, 0x00000000,
+			0xFFFFFFFF, 0xFFFFFFFF, 0x0000003F, 0x00000003,
+			0xFFFFD7C0, 0xFFFFFFFB, 0x547F7FFF, 0x000FFFFD,
+			0xFFFFDFFE, 0xFFFFFFFF, 0xDFFEFFFF, 0xFFFFFFFF,
+			0xFFFF007B, 0xFFFFFFFF, 0xFFFF199F, 0x033FCFFF,
+			0x00000000, 0xFFFE0000, 0x027FFFFF, 0xFFFFFFFE,
+			0xFFFE007F, 0xBBFFFFFB, 0xFFFF0016, 0x000707FF,
+			0x00000000, 0x07FFFFFE, 0x0007FFFF, 0xFFFF03FF,
+			0xFFFFFFFF, 0x7CFFFFFF, 0xFFEF7FFF, 0x03FF3DFF,
+			0xFFFFFFEE, 0xF3FFFFFF, 0xFF1E3FFF, 0x0000FFCF,
+			0xFFF99FEE, 0xD3C5FDFF, 0xB080399F, 0x0003FFCF,
+			0xFFF987E4, 0xD36DFDFF, 0x5E003987, 0x001FFFC0,
+			0xFFFBAFEE, 0xF3EDFDFF, 0x00003BBF, 0x0000FFC1,
+			0xFFF99FEE, 0xF3CDFDFF, 0xB0C0398F, 0x0000FFC3,
+			0xD63DC7EC, 0xC3BFC718, 0x00803DC7, 0x0000FF80,
+			0xFFFDDFEE, 0xC3EFFDFF, 0x00603DDF, 0x0000FFC3,
+			0xFFFDDFEC, 0xC3EFFDFF, 0x40603DDF, 0x0000FFC3,
+			0xFFFDDFEC, 0xC3FFFDFF, 0x00803DCF, 0x0000FFC3,
+			0x00000000, 0x00000000, 0x00000000, 0x00000000,
+			0xFFFFFFFE, 0x07FF7FFF, 0x03FF7FFF, 0x00000000,
+			0xFEF02596, 0x3BFF6CAE, 0x03FF3F5F, 0x00000000,
+			0x03000000, 0xC2A003FF, 0xFFFFFEFF, 0xFFFE03FF,
+			0xFEBF0FDF, 0x02FE3FFF, 0x00000000, 0x00000000,
+			0x00000000, 0x00000000, 0x00000000, 0x00000000,
+			0x00000000, 0x00000000, 0x1FFF0000, 0x00000002,
+			0x000000A0, 0x003EFFFE, 0xFFFFFFFE, 0xFFFFFFFF,
+			0x661FFFFF, 0xFFFFFFFE, 0xFFFFFFFF, 0x77FFFFFF
+		};
+	}
+}

+ 20 - 0
mcs/class/System.XML/System.Xml/XmlNameTable.cs

@@ -0,0 +1,20 @@
+// -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+//
+// System.Xml.XmlNameTable.cs
+//
+// Author:
+//   Jason Diamond ([email protected])
+//
+// (C) 2001 Jason Diamond  http://injektilo.org/
+//
+
+namespace System.Xml
+{
+	public abstract class XmlNameTable
+	{
+		public abstract string Add(string name);
+		public abstract string Add(char[] buffer, int offset, int length);
+		public abstract string Get(string name);
+		public abstract string Get(char[] buffer, int offset, int length);
+	}
+}

+ 22 - 0
mcs/class/System.XML/System.Xml/XmlNamespaceManager.cs

@@ -0,0 +1,22 @@
+// -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+//
+// System.Xml.XmlNamespaceManager.cs
+//
+// Author:
+//   Jason Diamond ([email protected])
+//
+// (C) 2001 Jason Diamond  http://injektilo.org/
+//
+
+using System.Collections;
+
+namespace System.Xml
+{
+	public class XmlNamespaceManager : IEnumerable
+	{
+		public IEnumerator GetEnumerator()
+		{
+			return null;
+		}
+	}
+}

+ 34 - 0
mcs/class/System.XML/System.Xml/XmlNodeType.cs

@@ -0,0 +1,34 @@
+// -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+//
+// System.Xml.XmlNodeType.cs
+//
+// Author:
+//   Jason Diamond ([email protected])
+//
+// (C) 2001 Jason Diamond  http://injektilo.org/
+//
+
+namespace System.Xml
+{
+	public enum XmlNodeType
+	{
+		Attribute,
+		CDATA,
+		Comment,
+		Document,
+		DocumentFragment,
+		DocumentType,
+		Element,
+		EndElement,
+		EndEntity,
+		Entity,
+		EntityReference,
+		None,
+		Notation,
+		ProcessingInstruction,
+		SignifigantWhitespace,
+		Text,
+		Whitespace,
+		XmlDeclaration
+	}
+}

+ 127 - 0
mcs/class/System.XML/System.Xml/XmlParserContext.cs

@@ -0,0 +1,127 @@
+// -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+//
+// System.Xml.XmlParserContext.cs
+//
+// Author:
+//   Jason Diamond ([email protected])
+//
+// (C) 2001 Jason Diamond  http://injektilo.org/
+//
+
+namespace System.Xml
+{
+	public class XmlParserContext
+	{
+		// constructors
+
+		public XmlParserContext(
+			XmlNameTable nameTable,
+			XmlNamespaceManager namespaceManager,
+			string xmlLang,
+			XmlSpace xmlSpace) :
+
+			this(
+				nameTable,
+				namespaceManager,
+				null,
+				null,
+				null,
+				null,
+				null,
+				xmlLang,
+				xmlSpace
+			)
+		{
+		}
+
+		public XmlParserContext(
+			XmlNameTable nameTable,
+			XmlNamespaceManager namespaceManager,
+			string docTypeName,
+			string publicID,
+			string systemID,
+			string internalSubset,
+			string baseURI,
+			string xmlLang,
+			XmlSpace xmlSpace)
+		{
+			this.nameTable = nameTable;
+			this.namespaceManager = namespaceManager;
+			this.docTypeName = docTypeName;
+			this.publicID = publicID;
+			this.systemID = systemID;
+			this.internalSubset = internalSubset;
+			this.baseURI = baseURI;
+			this.xmlLang = xmlLang;
+			this.xmlSpace = xmlSpace;
+		}
+
+		// properties
+
+		public string BaseURI
+		{
+			get { return baseURI; }
+			set { baseURI = value; }
+		}
+
+		public string DocTypeName
+		{
+			get { return docTypeName; }
+			set { docTypeName = value; }
+		}
+
+		public string InternalSubset
+		{
+			get { return internalSubset; }
+			set { internalSubset = value; }
+		}
+
+		public XmlNamespaceManager NamespaceManager
+		{
+			get { return namespaceManager; }
+			set { namespaceManager = value; }
+		}
+
+		public XmlNameTable NameTable
+		{
+			get { return nameTable; }
+			set { nameTable = nameTable; }
+		}
+
+		public string PublicId
+		{
+			get { return publicID; }
+			set { publicID = value; }
+		}
+
+		public string SystemId
+		{
+			get { return systemID; }
+			set { systemID = value; }
+		}
+
+		public string XmlLang
+		{
+			get { return xmlLang; }
+			set { xmlLang = value; }
+		}
+
+		public XmlSpace XmlSpace
+		{
+			get { return xmlSpace; }
+			set { xmlSpace = value; }
+		}
+
+		// privates
+
+		private string baseURI;
+		private string docTypeName;
+		private string internalSubset;
+		private XmlNamespaceManager namespaceManager;
+		private XmlNameTable nameTable;
+		private string publicID;
+		private string systemID;
+		private string xmlLang;
+		private XmlSpace xmlSpace;
+	}
+}

+ 238 - 0
mcs/class/System.XML/System.Xml/XmlReader.cs

@@ -0,0 +1,238 @@
+// -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+//
+// System.Xml.XmlReader.cs
+//
+// Author:
+//   Jason Diamond ([email protected])
+//
+// (C) 2001 Jason Diamond  http://injektilo.org/
+//
+
+namespace System.Xml
+{
+	public abstract class XmlReader
+	{
+		// properties
+
+		public abstract int AttributeCount { get; }
+
+		public abstract string BaseURI { get; }
+
+		public virtual bool CanResolveEntity
+		{
+			get
+			{
+				return false;
+			}
+		}
+
+		public abstract int Depth { get; }
+
+		public abstract bool EOF { get; }
+
+		public virtual bool HasAttributes
+		{
+			get
+			{
+				return AttributeCount > 0;
+			}
+		}
+
+		public abstract bool HasValue { get; }
+
+		public abstract bool IsDefault { get; }
+
+		public abstract bool IsEmptyElement { get; }
+
+		public abstract string this[int i] { get; }
+
+		public abstract string this[string name] { get; }
+
+		public abstract string this[
+			string localName,
+			string namespaceName]
+		{ get; }
+
+		public abstract string LocalName { get; }
+
+		public abstract string Name { get; }
+
+		public abstract string NamespaceURI { get; }
+
+		public abstract XmlNameTable NameTable { get; }
+
+		public abstract XmlNodeType NodeType { get; }
+
+		public abstract string Prefix { get; }
+
+		public abstract char QuoteChar { get; }
+
+		public abstract ReadState ReadState { get; }
+
+		public abstract string Value { get; }
+
+		public abstract string XmlLang { get; }
+
+		public abstract XmlSpace XmlSpace { get; }
+
+		// methods
+
+		public abstract void Close();
+
+		public abstract string GetAttribute(int i);
+
+		public abstract string GetAttribute(string name);
+
+		public abstract string GetAttribute(
+			string localName,
+			string namespaceName);
+
+		public static bool IsName(string s)
+		{
+			bool result = false;
+
+			if (s != null && s.Length > 0)
+			{
+				char[] chars = s.ToCharArray();
+
+				if (XmlChar.IsFirstNameChar(chars[0]))
+				{
+					int i = 1;
+					int n = chars.Length;
+
+					while (i < n && XmlChar.IsNameChar(chars[i]))
+					{
+						++i;
+					}
+
+					result = i == n;
+				}
+			}
+
+			return result;
+		}
+
+		public static bool IsNameToken(string s)
+		{
+			bool result = false;
+
+			if (s != null && s.Length > 0)
+			{
+				char[] chars = s.ToCharArray();
+
+				int i = 0;
+				int n = chars.Length;
+
+				while (i < n && XmlChar.IsNameChar(chars[i]))
+				{
+					++i;
+				}
+
+				result = i == n;
+			}
+
+			return result;
+		}
+
+		public virtual bool IsStartElement()
+		{
+			// TODO: implement me.
+			return false;
+		}
+
+		public virtual bool IsStartElement(string name)
+		{
+			// TODO: implement me.
+			return false;
+		}
+
+		public virtual bool IsStartElement(
+			string localName,
+			string namespaceName)
+		{
+			// TODO: implement me.
+			return false;
+		}
+
+		public abstract string LookupNamespace(string prefix);
+
+		public abstract void MoveToAttribute(int i);
+
+		public abstract bool MoveToAttribute(string name);
+
+		public abstract bool MoveToAttribute(
+			string localName,
+			string namespaceName);
+
+		public virtual XmlNodeType MoveToContent()
+		{
+			// TODO: implement me.
+			return XmlNodeType.None;
+		}
+
+		public abstract bool MoveToElement();
+
+		public abstract bool MoveToFirstAttribute();
+
+		public abstract bool MoveToNextAttribute();
+
+		public abstract bool Read();
+
+		public abstract bool ReadAttributeValue();
+
+		public virtual string ReadElementString()
+		{
+			// TODO: implement me.
+			return null;
+		}
+
+		public virtual string ReadElementString(string name)
+		{
+			// TODO: implement me.
+			return null;
+		}
+
+		public virtual string ReadElementString(
+			string localName,
+			string namespaceName)
+		{
+			// TODO: implement me.
+			return null;
+		}
+
+		public virtual void ReadEndElement()
+		{
+			// TODO: implement me.
+		}
+
+		public abstract string ReadInnerXml();
+
+		public abstract string ReadOuterXml();
+
+		public virtual void ReadStartElement()
+		{
+			// TODO: implement me.
+		}
+
+		public virtual void ReadStartElement(string name)
+		{
+			// TODO: implement me.
+		}
+
+		public virtual void ReadStartElement(
+			string localName,
+			string namespaceName)
+		{
+			// TODO: implement me.
+		}
+
+		public abstract string ReadString();
+
+		public abstract void ResolveEntity();
+
+		public virtual void Skip()
+		{
+			// TODO: implement me.
+		}
+	}
+}

+ 19 - 0
mcs/class/System.XML/System.Xml/XmlSpace.cs

@@ -0,0 +1,19 @@
+// -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+//
+// System.Xml.XmlSpace.cs
+//
+// Author:
+//   Jason Diamond ([email protected])
+//
+// (C) 2001 Jason Diamond  http://injektilo.org/
+//
+
+namespace System.Xml
+{
+	public enum XmlSpace
+	{
+		Default,
+		None,
+		Preserve
+	}
+}

+ 797 - 0
mcs/class/System.XML/System.Xml/XmlTextReader.cs

@@ -0,0 +1,797 @@
+// -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+//
+// System.Xml.XmlTextReader.cs
+//
+// Author:
+//   Jason Diamond ([email protected])
+//
+// (C) 2001 Jason Diamond  http://injektilo.org/
+//
+
+// FIXME:
+//   This can only parse basic XML: elements, attributes, processing
+//   instructions, and comments are OK but there's no support for
+//   entity/character references or namespaces yet.
+//
+//   It barfs on DOCTYPE declarations and CDATA sections.
+//
+//   There's also no checking being done for either well-formedness
+//   or validity.
+//
+//   ParserContext and NameTables aren't being used yet.
+//
+//   The XmlTextReader-specific properties and methods have yet to
+//   be added or implemented.
+//
+//   Some thought needs to be given to performance. There's too many
+//   strings and string builders being allocated.
+//
+//   None of the MoveTo methods have been implemented yet.
+//
+//   LineNumber and LinePosition aren't being tracked.
+//
+//   xml:space, xml:lang, and xml:base aren't being tracked.
+//
+//   Depth isn't being tracked.
+
+using System;
+using System.Collections;
+using System.IO;
+using System.Net;
+using System.Text;
+
+namespace System.Xml
+{
+	public class XmlTextReader : XmlReader
+	{
+		// constructors
+
+		protected XmlTextReader()
+		{
+			Init();
+		}
+
+		public XmlTextReader(Stream input)
+		{
+			Init();
+			reader = new StreamReader(
+				input,
+				Encoding.UTF8,
+				true);
+		}
+
+		public XmlTextReader(string url)
+		{
+			Init();
+			WebClient client = new WebClient();
+			reader = new StreamReader(
+				client.OpenRead(url),
+				Encoding.UTF8,
+				true);
+		}
+
+		public XmlTextReader(TextReader input)
+		{
+			Init();
+			reader = input;
+		}
+
+ 		public XmlTextReader(Stream input, XmlNameTable nameTable)
+ 		{
+			// TODO: implement me.
+			throw new NotImplementedException();
+		}
+
+		public XmlTextReader(string baseURI, Stream input)
+		{
+			// TODO: implement me.
+			throw new NotImplementedException();
+		}
+
+		public XmlTextReader(string baseURI, TextReader input)
+		{
+			// TODO: implement me.
+			throw new NotImplementedException();
+		}
+
+		public XmlTextReader(string url, XmlNameTable nameTable)
+		{
+			// TODO: implement me.
+			throw new NotImplementedException();
+		}
+
+		public XmlTextReader(
+			TextReader input,
+			XmlNameTable nameTable)
+		{
+			// TODO: implement me.
+			throw new NotImplementedException();
+		}
+
+		public XmlTextReader(
+			Stream inputFragment,
+			XmlNodeType fragmentType,
+			XmlParserContext context)
+		{
+			// TODO: implement me.
+			throw new NotImplementedException();
+		}
+
+		public XmlTextReader(
+			string baseURI,
+			Stream input,
+			XmlNameTable nameTable)
+		{
+			// TODO: implement me.
+			throw new NotImplementedException();
+		}
+
+		public XmlTextReader(
+			string baseURI,
+			TextReader input,
+			XmlNameTable nameTable)
+		{
+			// TODO: implement me.
+			throw new NotImplementedException();
+		}
+
+		public XmlTextReader(
+			string fragment,
+			XmlNodeType fragmentType,
+			XmlParserContext context)
+		{
+			// TODO: implement me.
+			throw new NotImplementedException();
+		}
+
+		// properties
+
+		public override int AttributeCount
+		{
+			get
+			{
+				return attributes.Count;
+			}
+		}
+
+		public override string BaseURI
+		{
+			get
+			{
+				// TODO: implement me.
+				return null;
+			}
+		}
+
+		public override bool CanResolveEntity
+		{
+			get
+			{
+				// TODO: implement me.
+				return false;
+			}
+		}
+
+		public override int Depth
+		{
+			get
+			{
+				// TODO: implement me.
+				return 0;
+			}
+		}
+
+		public override bool EOF
+		{
+			get
+			{
+				return
+					readState == ReadState.EndOfFile ||
+					readState == ReadState.Closed;
+			}
+		}
+
+		public override bool HasValue
+		{
+			get
+			{
+				return value != String.Empty;
+			}
+		}
+
+		public override bool IsDefault
+		{
+			get
+			{
+				// TODO: implement me.
+				return false;
+			}
+		}
+
+		public override bool IsEmptyElement
+		{
+			get
+			{
+				return isEmptyElement;
+			}
+		}
+
+		public override string this[int i]
+		{
+			get
+			{
+				return GetAttribute(i);
+			}
+		}
+
+		public override string this[string name]
+		{
+			get
+			{
+				return GetAttribute(name);
+			}
+		}
+
+		public override string this[
+			string localName,
+			string namespaceName]
+		{
+			get
+			{
+				return GetAttribute(localName, namespaceName);
+			}
+		}
+
+		public override string LocalName
+		{
+			get
+			{
+				// TODO: implement me.
+				return null;
+			}
+		}
+
+		public override string Name
+		{
+			get
+			{
+				return name;
+			}
+		}
+
+		public override string NamespaceURI
+		{
+			get
+			{
+				// TODO: implement me.
+				return null;
+			}
+		}
+
+		public override XmlNameTable NameTable
+		{
+			get
+			{
+				// TODO: implement me.
+				return null;
+			}
+		}
+
+		public override XmlNodeType NodeType
+		{
+			get
+			{
+				return nodeType;
+			}
+		}
+
+		public override string Prefix
+		{
+			get
+			{
+				// TODO: implement me.
+				return null;
+			}
+		}
+
+		public override char QuoteChar
+		{
+			get
+			{
+				// TODO: implement me.
+				return '"';
+			}
+		}
+
+		public override ReadState ReadState
+		{
+			get
+			{
+				return readState;
+			}
+		}
+
+		public override string Value
+		{
+			get
+			{
+				return value;
+			}
+		}
+
+		public override string XmlLang
+		{
+			get
+			{
+				// TODO: implement me.
+				return null;
+			}
+		}
+
+		public override XmlSpace XmlSpace
+		{
+			get
+			{
+				// TODO: implement me.
+				return XmlSpace.Default;
+			}
+		}
+
+		// methods
+
+		public override void Close()
+		{
+			readState = ReadState.Closed;
+		}
+
+		public override string GetAttribute(int i)
+		{
+			// TODO: implement me.
+			return null;
+		}
+
+		public override string GetAttribute(string name)
+		{
+			return (string)attributes[name];
+		}
+
+		public override string GetAttribute(
+			string localName,
+			string namespaceName)
+		{
+			// TODO: implement me.
+			return null;
+		}
+
+		public override string LookupNamespace(string prefix)
+		{
+			// TODO: implement me.
+			return null;
+		}
+
+		public override void MoveToAttribute(int i)
+		{
+			// TODO: implement me.
+		}
+
+		public override bool MoveToAttribute(string name)
+		{
+			// TODO: implement me.
+			return false;
+		}
+
+		public override bool MoveToAttribute(
+			string localName,
+			string namespaceName)
+		{
+			// TODO: implement me.
+			return false;
+		}
+
+		public override bool MoveToElement()
+		{
+			// TODO: implement me.
+			return false;
+		}
+
+		public override bool MoveToFirstAttribute()
+		{
+			// TODO: implement me.
+			return false;
+		}
+
+		public override bool MoveToNextAttribute()
+		{
+			// TODO: implement me.
+			return false;
+		}
+
+		public override bool Read()
+		{
+			bool more = false;
+
+			readState = ReadState.Interactive;
+
+			more = ReadContent();
+
+			return more;
+		}
+
+		public override bool ReadAttributeValue()
+		{
+			// TODO: implement me.
+			return false;
+		}
+
+		public override string ReadInnerXml()
+		{
+			// TODO: implement me.
+			return null;
+		}
+
+		public override string ReadOuterXml()
+		{
+			// TODO: implement me.
+			return null;
+		}
+
+		public override string ReadString()
+		{
+			// TODO: implement me.
+			return null;
+		}
+
+		public override void ResolveEntity()
+		{
+			// TODO: implement me.
+		}
+
+		// privates
+
+		private TextReader reader;
+		private ReadState readState;
+
+		private XmlNodeType nodeType;
+		private string name;
+		private bool isEmptyElement;
+		private string value;
+		private Hashtable attributes;
+
+		private void Init()
+		{
+			readState = ReadState.Initial;
+
+			nodeType = XmlNodeType.None;
+			name = String.Empty;
+			isEmptyElement = false;
+			value = String.Empty;
+			attributes = new Hashtable();
+		}
+
+		// Use this method rather than setting the properties
+		// directly so that all the necessary properties can
+		// be changed in harmony with each other. Maybe the
+		// fields should be in a seperate class to help enforce
+		// this.
+		private void SetProperties(
+			XmlNodeType nodeType,
+			string name,
+			bool isEmptyElement,
+			string value,
+			bool clearAttributes)
+		{
+			this.nodeType = nodeType;
+			this.name = name;
+			this.isEmptyElement = isEmptyElement;
+			this.value = value;
+
+			if (clearAttributes)
+			{
+				ClearAttributes();
+			}
+		}
+
+		private void AddAttribute(string name, string value)
+		{
+			attributes.Add(name, value);
+		}
+
+		private void ClearAttributes()
+		{
+			attributes.Clear();
+		}
+
+		// This should really keep track of some state so
+		// that it's not possible to have more than one document
+		// element or text outside of the document element.
+		private bool ReadContent()
+		{
+			bool more = false;
+
+			switch (reader.Peek())
+			{
+			case '<':
+				reader.Read();
+				ReadTag();
+				more = true;
+				break;
+			case -1:
+				readState = ReadState.EndOfFile;
+				SetProperties(
+					XmlNodeType.None, // nodeType
+					String.Empty, // name
+					false, // isEmptyElement
+					String.Empty, // value
+					true // clearAttributes
+				);
+				more = false;
+				break;
+			default:
+				ReadText();
+				more = true;
+				break;
+			}
+
+			return more;
+		}
+
+		// The leading '<' has already been consumed.
+		private void ReadTag()
+		{
+			switch (reader.Peek())
+			{
+			case '/':
+				reader.Read();
+				ReadEndTag();
+				break;
+			case '?':
+				reader.Read();
+				ReadProcessingInstruction();
+				break;
+			case '!':
+				reader.Read();
+				ReadComment();
+				break;
+			default:
+				ReadStartTag();
+				break;
+			}
+		}
+
+		// The leading '<' has already been consumed.
+		private void ReadStartTag()
+		{
+			string name = ReadName();
+			SkipWhitespace();
+
+			bool isEmptyElement = false;
+
+			ClearAttributes();
+
+			if (XmlChar.IsFirstNameChar(reader.Peek()))
+			{
+				ReadAttributes();
+			}
+
+			if (reader.Peek() == '/')
+			{
+				reader.Read();
+				isEmptyElement = true;
+			}
+
+			Expect('>');
+
+			SetProperties(
+				XmlNodeType.Element, // nodeType
+				name, // name
+				isEmptyElement, // isEmptyElement
+				String.Empty, // value
+				false // clearAttributes
+			);
+		}
+
+		// The reader is positioned on the first character
+		// of the element's name.
+		private void ReadEndTag()
+		{
+			string name = ReadName();
+			SkipWhitespace();
+			Expect('>');
+
+			SetProperties(
+				XmlNodeType.EndElement, // nodeType
+				name, // name
+				false, // isEmptyElement
+				String.Empty, // value
+				true // clearAttributes
+			);
+		}
+
+		// The reader is positioned on the first character
+		// of the text.
+		private void ReadText()
+		{
+			StringBuilder text = new StringBuilder();
+			text.Append((char)reader.Read());
+
+			while (reader.Peek() != '<' && reader.Peek() != -1)
+			{
+				text.Append((char)reader.Read());
+			}
+
+			SetProperties(
+				XmlNodeType.Text, // nodeType
+				String.Empty, // name
+				false, // isEmptyElement
+				text.ToString(), // value
+				true // clearAttributes
+			);
+		}
+
+		// The reader is positioned on the first character of
+		// the attribute name.
+		private void ReadAttributes()
+		{
+			do
+			{
+				string name = ReadName();
+				SkipWhitespace();
+				Expect('=');
+				SkipWhitespace();
+				string value = ReadAttribute();
+				SkipWhitespace();
+
+				AddAttribute(name, value);
+			}
+			while (reader.Peek() != '/' && reader.Peek() != '>' && reader.Peek() != -1);
+		}
+
+		// The reader is positioned on the quote character.
+		private string ReadAttribute()
+		{
+			int quoteChar = reader.Read();
+
+			if (quoteChar != '\'' && quoteChar != '\"')
+			{
+				throw new Exception("an attribute value was not quoted");
+			}
+
+			StringBuilder valueBuilder = new StringBuilder();
+
+			while (reader.Peek() != quoteChar)
+			{
+				int ch = reader.Read();
+
+				switch (ch)
+				{
+				case '<':
+					throw new Exception("attribute values cannot contain '<'");
+				case -1:
+					throw new Exception("unexpected end of file in an attribute value");
+				}
+
+				valueBuilder.Append((char)ch);
+			}
+
+			reader.Read();
+
+			return valueBuilder.ToString();
+		}
+
+		// The reader is positioned on the first character
+		// of the target.
+		private void ReadProcessingInstruction()
+		{
+			string target = ReadName();
+			SkipWhitespace();
+
+			StringBuilder valueBuilder = new StringBuilder();
+
+			while (reader.Peek() != -1)
+			{
+				int ch = reader.Read();
+
+				if (ch == '?' && reader.Peek() == '>')
+				{
+					reader.Read();
+					break;
+				}
+
+				valueBuilder.Append((char)ch);
+			}
+
+			SetProperties(
+				XmlNodeType.ProcessingInstruction, // nodeType
+				target, // name
+				false, // isEmptyElement
+				valueBuilder.ToString(), // value
+				true // clearAttributes
+			);
+		}
+
+		// The reader is positioned on the first character after
+		// the leading '<!'.
+		private void ReadComment()
+		{
+			Expect('-');
+			Expect('-');
+
+			StringBuilder valueBuilder = new StringBuilder();
+
+			while (reader.Peek() != -1)
+			{
+				int ch = reader.Read();
+
+				if (ch == '-' && reader.Peek() == '-')
+				{
+					reader.Read();
+
+					if (reader.Peek() != '>')
+					{
+						throw new Exception("comments cannot contain '--'");
+					}
+
+					reader.Read();
+					break;
+				}
+
+				valueBuilder.Append((char)ch);
+			}
+
+			SetProperties(
+				XmlNodeType.Comment, // nodeType
+				String.Empty, // name
+				false, // isEmptyElement
+				valueBuilder.ToString(), // value
+				true // clearAttributes
+			);
+		}
+
+		// The reader is positioned on the first character
+		// of the name.
+		private string ReadName()
+		{
+			if (!XmlChar.IsFirstNameChar(reader.Peek()))
+			{
+				throw new Exception("a name did not start with a legal character");
+			}
+
+			StringBuilder nameBuilder = new StringBuilder();
+
+			nameBuilder.Append((char)reader.Read());
+
+			while (XmlChar.IsNameChar(reader.Peek()))
+			{
+				nameBuilder.Append((char)reader.Read());
+			}
+
+			return nameBuilder.ToString();
+		}
+
+		// Read the next character and compare it against the
+		// specified character.
+		private void Expect(int expected)
+		{
+			int ch = reader.Read();
+
+			if (ch != expected)
+			{
+				throw new Exception(String.Format(
+					"expected '{0}' ({1:X}) but found '{2}' ({3:X})",
+					(char)expected,
+					expected,
+					(char)ch,
+					ch));
+			}
+		}
+
+		// Does not consume the first non-whitespace character.
+		private void SkipWhitespace()
+		{
+			while (XmlChar.IsWhitespace(reader.Peek()))
+			{
+				reader.Read();
+			}
+		}
+	}
+}

+ 8 - 0
mcs/class/System.XML/System.Xml/common.src

@@ -0,0 +1,8 @@
+XmlChar.cs
+XmlNameTable.cs
+XmlNamespaceManager.cs
+XmlNodeType.cs
+XmlParserContext.cs
+XmlReader.cs
+XmlSpace.cs
+XmlTextReader.cs

+ 14 - 0
mcs/class/System.XML/makefile

@@ -0,0 +1,14 @@
+all:
+	@echo "You must use 'make windows' or 'make unix'."
+	@echo "'make unix' is broken for now."
+
+windows: make-list
+	$(CSC) /target:library /out:System.XML.dll /nowarn:1595 @list
+
+unix:
+	@echo "'make unix' is broken for now."
+
+make-list:
+	cat $$i/common.src $$i/windows.src | sed "s/^/$$i\\\\/";
+
+test: $(PLATFORM)

+ 1 - 1
mcs/class/makefile

@@ -7,7 +7,7 @@ all:
 
 windows:
 	for i in $(DIRS); do				\
-		(cd $$i; CSC=$(CSC) make windows) 	\
+		(cd $$i; CSC=$(CSC) NUNIT_CONSOLE=NUnitConsole.exe PLATFORM=window make windows)\
 	done;
 
 unix: