Преглед изворни кода

2003-03-18 Atsushi Enomoto <[email protected]>

	* added XmlParserInput.cs for multi xml document sources.
	* added DTDObjectModel.cs (maybe temporary).
	* XmlTextReader.cs :
	  + fixed ctor to use XmlStreamReader. Allowed null XmlParserContext.
	  + Some members such as LineNumber, ReadChar now uses XmlParserInput.
	  + added support for Namespaces (namespace-ignorant parse available).
	  + added support for XmlResolver.
	  + replace SetReaderContext()/SetReaderFragment() with Initialize().
	  + use NameTable in CreateNameString.
	  + fixed ReadCData(). Now reads "]]]>" correctly.
	  + support for DTD parse.
	  + Read() now throws an error when it reached EOF while Depth > 0.
	* XmlAttribute.cs,
	  XmlDocumentFragment.cs,
	  XmlElement.cs : fix related to the changes of XmlTextReader.Initialize
	* XmlDocument.cs : ReadNode() now reads DocumentType.
	* XmlDocumentType.cs : implemented Entities, Notations, WriteTo().
	* XmlEntity.cs,
	  XmlNotation.cs : added override LastLinkedChild (for doctype node).
	* XmlNamedNodeMap.cs : Remove() raises an error if target is read only.
	* XmlElement.cs : bugfix for node removal of set_InnerXml.
	* XmlNode.cs : added insertBeforeIntern() derived from InsertBefore().
	  (to append child XmlEntity into XmlDocumentType correctly.)
	* XmlInputStream.cs : fixed to access file with FileAccess.Read.

svn path=/trunk/mcs/; revision=12619
Atsushi Eno пре 23 година
родитељ
комит
8a88d4db75

+ 27 - 0
mcs/class/System.XML/System.Xml/ChangeLog

@@ -1,3 +1,30 @@
+2003-03-18  Atsushi Enomoto <[email protected]>
+
+	* added XmlParserInput.cs for multi xml document sources.
+	* added DTDObjectModel.cs (maybe temporary).
+	* XmlTextReader.cs :
+	  + fixed ctor to use XmlStreamReader. Allowed null XmlParserContext.
+	  + Some members such as LineNumber, ReadChar now uses XmlParserInput.
+	  + added support for Namespaces (namespace-ignorant parse available).
+	  + added support for XmlResolver.
+	  + replace SetReaderContext()/SetReaderFragment() with Initialize().
+	  + use NameTable in CreateNameString.
+	  + fixed ReadCData(). Now reads "]]]>" correctly.
+	  + support for DTD parse.
+	  + Read() now throws an error when it reached EOF while Depth > 0.
+	* XmlAttribute.cs,
+	  XmlDocumentFragment.cs,
+	  XmlElement.cs : fix related to the changes of XmlTextReader.Initialize
+	* XmlDocument.cs : ReadNode() now reads DocumentType.
+	* XmlDocumentType.cs : implemented Entities, Notations, WriteTo().
+	* XmlEntity.cs,
+	  XmlNotation.cs : added override LastLinkedChild (for doctype node).
+	* XmlNamedNodeMap.cs : Remove() raises an error if target is read only.
+	* XmlElement.cs : bugfix for node removal of set_InnerXml.
+	* XmlNode.cs : added insertBeforeIntern() derived from InsertBefore().
+	  (to append child XmlEntity into XmlDocumentType correctly.)
+	* XmlInputStream.cs : fixed to access file with FileAccess.Read.
+
 2003-03-15  Duncan Mak  <[email protected]>
 
 	* XmlElement.cs (Name): Only append prefix + ':' when prefix is

+ 165 - 0
mcs/class/System.XML/System.Xml/DTDObjectModel.cs

@@ -0,0 +1,165 @@
+//
+// Mono.Xml.DTDObjectModel
+//
+// Author:
+//	Atsushi Enomoto ([email protected])
+//
+//	(C)2003 Atsushi Enomoto
+//
+using System;
+using System.Collections;
+using System.Xml;
+
+namespace Mono.Xml
+{
+
+	public class DTDObjectModel
+	{
+		public DTDObjectModel ()
+		{
+		}
+
+		internal Hashtable ElementDecls = new Hashtable ();
+		internal Hashtable AttListDecls = new Hashtable ();
+		internal Hashtable EntityDecls = new Hashtable ();
+		internal Hashtable NotationDecls = new Hashtable ();
+
+		[MonoTODO()]
+		public string BaseURI {
+			// XmlStreamParser.BaseURI
+			get { return baseURI; }
+		}
+
+		public string Name;
+		
+		public string PublicId;
+		
+		public string SystemId;
+		
+		public string InternalSubset;
+		
+		string baseURI;
+	}
+
+	public enum DTDContentOrderType
+	{
+		None,
+		Seq,
+		Or
+	}
+
+	public enum DTDAttributeType
+	{
+		None,
+		CData,
+		Id,
+		IdRef,
+		IdRefs,
+		Entity,
+		Entities,
+		NmToken,
+		NmTokens,
+		Notation
+	}
+
+	public enum DTDAttributeOccurenceType
+	{
+		None,
+		Required,
+		Optional,
+		Fixed
+	}
+
+	public class DTDContentModel
+	{
+		public string ElementName;
+		public DTDContentOrderType OrderType = DTDContentOrderType.None;
+		public ArrayList ChildModels = new ArrayList ();
+		public decimal MinOccurs = 1;
+		public decimal MaxOccurs = 1;
+
+		internal DTDContentModel () {}
+	}
+
+	public class DTDElementDeclaration : ICloneable
+	{
+		public string Name;
+		public bool IsEmpty;
+		public bool IsAny;
+		public bool IsMixedContent;
+		public DTDContentModel ContentModel = new DTDContentModel ();
+
+		internal DTDElementDeclaration () {}
+
+		public object Clone ()
+		{
+			return this.MemberwiseClone ();
+		}
+	}
+
+	public class DTDAttributeDefinition : ICloneable
+	{
+		public string Name;
+		public DTDAttributeType AttributeType = DTDAttributeType.None;
+		// entity reference inside enumerated values are not allowed,
+		// but on the other hand, they are allowed inside default value.
+		// Then I decided to use string ArrayList for enumerated values,
+		// and unresolved string value for DefaultValue.
+		public ArrayList EnumeratedAttributeDeclaration = new ArrayList ();
+		public string UnresolvedDefaultValue = null;
+		public ArrayList EnumeratedNotations = new ArrayList();
+		public DTDAttributeOccurenceType OccurenceType = DTDAttributeOccurenceType.None;
+
+		internal DTDAttributeDefinition () {}
+
+		public object Clone ()
+		{
+			return this.MemberwiseClone ();
+		}
+	}
+
+	public class DTDAttListDeclaration : ICloneable
+	{
+		public string Name;
+		public Hashtable AttributeDefinitions = new Hashtable ();
+
+		internal DTDAttListDeclaration () {}
+
+		public object Clone ()
+		{
+			return this.MemberwiseClone ();
+		}
+	}
+
+	public class DTDEntityDeclaration
+	{
+		public string Name;
+		public string PublicId;
+		public string SystemId;
+		public string NotationName;
+		// FIXME: should have more complex value than simple string
+		public string EntityValue;
+
+		internal DTDEntityDeclaration () {}
+	}
+
+	public class DTDNotationDeclaration
+	{
+		public string Name;
+		public string LocalName;
+		public string Prefix;
+		public string PublicId;
+		public string SystemId;
+
+		internal DTDNotationDeclaration () {}
+	}
+
+	public class DTDParameterEntityDeclaration
+	{
+		public string Name;
+		public string PublicId;
+		public string SystemId;
+		public string BaseURI;
+		public string Value;
+	}
+}

+ 1 - 2
mcs/class/System.XML/System.Xml/XmlAttribute.cs

@@ -86,8 +86,7 @@ namespace System.Xml
 				XmlNamespaceManager nsmgr = ConstructNamespaceManager ();
 				XmlParserContext ctx = new XmlParserContext (OwnerDocument.NameTable, nsmgr, XmlLang, this.XmlSpace);
 				XmlTextReader xtr = OwnerDocument.ReusableReader;
-				xtr.SetReaderContext (BaseURI, ctx);
-				xtr.SetReaderFragment (new System.IO.StringReader ("'" + value.Replace ("'", "&apos;") + "'"), XmlNodeType.Attribute);
+				xtr.Initialize (BaseURI, ctx, new System.IO.StringReader ("'" + value.Replace ("'", "&apos;") + "'"), XmlNodeType.Attribute);
 
 				OwnerDocument.ReadAttributeNodeValue (xtr, this);
 			}

+ 33 - 12
mcs/class/System.XML/System.Xml/XmlDocument.cs

@@ -20,6 +20,7 @@ using System.Text;
 using System.Xml.XPath;
 using System.Diagnostics;
 using System.Collections;
+using Mono.Xml;
 using Mono.Xml.Native;
 
 namespace System.Xml
@@ -553,8 +554,7 @@ namespace System.Xml
 
 		public virtual void Load (Stream inStream)
 		{
-			XmlReader xmlReader = new XmlTextReader (new XmlInputStream (inStream));
-			Load (xmlReader);
+			Load (new XmlTextReader (new XmlStreamReader (inStream)));
 		}
 
 		public virtual void Load (string filename)
@@ -684,11 +684,9 @@ namespace System.Xml
 			}
 		}
 
-		[MonoTODO("DTD parser is not completed.")]
+		[MonoTODO ("Child of entity is not simple Value string;Get prefix of NotationDecl")]
 		public virtual XmlNode ReadNode(XmlReader reader)
 		{
-			// This logic was formerly defined in 'XmlNode.ConstructDOM()'
-
 			XmlNode resultNode = null;
 			XmlNode newNode = null;
 			XmlNode currentNode = null;
@@ -696,9 +694,7 @@ namespace System.Xml
 			if (reader.ReadState == ReadState.Initial)
 				reader.Read ();
 
-			// It was originally XmlDocument.Load(reader reader) when mcs was v0.16.
 			int startDepth = reader.Depth;
-//			bool atStart = true;
 			bool ignoredWhitespace;
 			bool reachedEOF = false;
 
@@ -777,7 +773,7 @@ namespace System.Xml
 					break;
 
 				case XmlNodeType.DocumentType:
-					// This logic is kinda hack;-)
+					// hack ;-)
 					XmlTextReader xtReader = reader as XmlTextReader;
 					if(xtReader == null) {
 						xtReader = new XmlTextReader (reader.ReadOuterXml (),
@@ -785,10 +781,7 @@ namespace System.Xml
 							new XmlParserContext (NameTable, ConstructNamespaceManager(), XmlLang, XmlSpace));
 						xtReader.Read ();
 					}
-					newNode = CreateDocumentType (xtReader.Name,
-						xtReader.GetAttribute ("PUBLIC"),
-						xtReader.GetAttribute ("SYSTEM"),
-						xtReader.Value);
+					newNode = ReadDoctypeNode (xtReader);
 					if(currentNode != null)
 						throw new XmlException ("XmlDocumentType at invalid position.");
 					break;
@@ -821,6 +814,34 @@ namespace System.Xml
 			return resultNode != null ? resultNode : newNode;
 		}
 
+		private XmlDocumentType ReadDoctypeNode (XmlTextReader xtReader)
+		{
+			XmlDocumentType doctype = CreateDocumentType (xtReader.Name,
+				xtReader.GetAttribute ("PUBLIC"),
+				xtReader.GetAttribute ("SYSTEM"),
+				xtReader.Value);
+			DTDObjectModel subset = xtReader.currentSubset;
+			foreach (DTDEntityDeclaration decl in subset.EntityDecls.Values) {
+				XmlNode n = new XmlEntity (decl.Name, decl.NotationName,
+					decl.PublicId, decl.SystemId, this);
+				// FIXME: Value is more complex, similar to Attribute.
+				n.insertBeforeIntern (this.CreateTextNode (decl.EntityValue), null);
+				doctype.entities.Nodes.Add (n);
+			}
+			foreach (DTDNotationDeclaration decl in subset.NotationDecls.Values) {
+				XmlNode n = new XmlNotation (decl.LocalName, decl.Prefix,
+					decl.PublicId, decl.SystemId, this);
+				doctype.notations.Nodes.Add (n);
+			}
+			foreach (DTDElementDeclaration decl in subset.ElementDecls.Values) {
+				doctype.elementDecls.Add (decl.Name, decl.Clone ());
+			}
+			foreach (DTDAttListDeclaration decl in subset.AttListDecls.Values) {
+				doctype.attListDecls.Add (decl.Name, decl.Clone ());
+			}
+			return doctype;
+		}
+
 		public virtual void Save(Stream outStream)
 		{
 			XmlTextWriter xmlWriter = new XmlTextWriter (outStream, Encoding.UTF8);

+ 1 - 2
mcs/class/System.XML/System.Xml/XmlDocumentFragment.cs

@@ -45,8 +45,7 @@ namespace System.Xml
 				XmlNamespaceManager nsmgr = this.ConstructNamespaceManager ();
 				XmlParserContext ctx = new XmlParserContext (nt, nsmgr, XmlLang, this.XmlSpace);
 				XmlTextReader xmlReader = OwnerDocument.ReusableReader;
-				xmlReader.SetReaderContext (String.Empty, ctx);
-				xmlReader.SetReaderFragment (new StringReader (value), XmlNodeType.DocumentFragment);
+				xmlReader.Initialize (String.Empty, ctx, new StringReader (value), XmlNodeType.Element);
 
 				do {
 					XmlNode n = OwnerDocument.ReadNode (xmlReader);

+ 15 - 6
mcs/class/System.XML/System.Xml/XmlDocumentType.cs

@@ -2,9 +2,12 @@
 // System.Xml.XmlDocumentType.cs
 //
 // Author: Duncan Mak ([email protected])
+//	   Atsushi Enomoto ([email protected])
 //
 // (C) Ximian, Inc.
 //
+using System;
+using System.Collections;
 
 namespace System.Xml
 {
@@ -15,7 +18,11 @@ namespace System.Xml
 		string publicId;        // public identifier on the DOCTYPE
 		string systemId;        // system identifier on the DOCTYPE
 		string internalSubset;  // value of the DTD internal subset
-		
+		internal XmlNamedNodeMap entities;
+		internal XmlNamedNodeMap notations;
+		internal Hashtable elementDecls;
+		internal Hashtable attListDecls;
+
 		// Constructor
 		protected internal XmlDocumentType (string name, string publicId,
 						    string systemId, string internalSubset,
@@ -26,14 +33,17 @@ namespace System.Xml
 			this.publicId = publicId;
 			this.systemId = systemId;
 			this.internalSubset = internalSubset;
+			entities = new XmlNamedNodeMap (this);
+			notations = new XmlNamedNodeMap (this);
+			elementDecls = new Hashtable ();
+			attListDecls = new Hashtable ();
 		}
 
 
 		// Properties
-		[MonoTODO]
 		public XmlNamedNodeMap Entities
 		{
-			get { return null; }
+			get { return entities; }
 		}
 			
 		public string InternalSubset
@@ -61,10 +71,9 @@ namespace System.Xml
 			get { return XmlNodeType.DocumentType; }
 		}
 
-		[MonoTODO]
 		public XmlNamedNodeMap Notations
 		{
-			get { return null; }
+			get { return notations; }
 		}
 
 		public string PublicId
@@ -90,9 +99,9 @@ namespace System.Xml
 			// No effect
 		}
 
-		[MonoTODO]
 		public override void WriteTo (XmlWriter w)
 		{
+			w.WriteDocType (name, publicId, systemId, internalSubset);
 		}
 	}
 }

+ 3 - 4
mcs/class/System.XML/System.Xml/XmlElement.cs

@@ -85,16 +85,15 @@ namespace System.Xml
 				return base.InnerXml;
 			}
 			set {
-				foreach(XmlNode n in ChildNodes)
-					this.RemoveChild(n);
+				while (FirstChild != null)
+					this.RemoveChild (FirstChild);
 
 				// I hope there are any well-performance logic...
 				XmlNameTable nt = this.OwnerDocument.NameTable;
 				XmlNamespaceManager nsmgr = this.ConstructNamespaceManager ();
 				XmlParserContext ctx = new XmlParserContext (nt, nsmgr, XmlLang, this.XmlSpace);
 				XmlTextReader xmlReader = OwnerDocument.ReusableReader;
-				xmlReader.SetReaderContext (String.Empty, ctx);
-				xmlReader.SetReaderFragment (new StringReader (value), XmlNodeType.DocumentFragment);
+				xmlReader.Initialize (String.Empty, ctx, new StringReader (value), XmlNodeType.Element);
 
 				do {
 					XmlNode n = OwnerDocument.ReadNode (xmlReader);

+ 7 - 0
mcs/class/System.XML/System.Xml/XmlEntity.cs

@@ -33,6 +33,7 @@ namespace System.Xml
 		string publicId;
 		string systemId;
 		string baseUri;
+		XmlLinkedNode lastChild;
 
 		#endregion
 
@@ -57,6 +58,12 @@ namespace System.Xml
 			get { return true; } // always read-only.
 		}
 
+		internal override XmlLinkedNode LastLinkedChild {
+			get { return lastChild; }
+
+			set { lastChild = value; }
+		}
+
 		public override string LocalName {
 			get { return name; }
 		}

+ 3 - 3
mcs/class/System.XML/System.Xml/XmlInputStream.cs

@@ -17,7 +17,7 @@ namespace Mono.Xml.Native
 	#region XmlStreamReader
 	public class XmlStreamReader : StreamReader
 	{
-		public XmlStreamReader (XmlInputStream input)
+		XmlStreamReader (XmlInputStream input)
 			: base (input, input.ActualEncoding != null ? input.ActualEncoding : Encoding.UTF8)
 		{
 		}
@@ -34,7 +34,7 @@ namespace Mono.Xml.Native
 	}
 	#endregion
 
-	public class XmlInputStream : Stream
+	class XmlInputStream : Stream
 	{
 		Encoding enc;
 		Stream stream;
@@ -54,7 +54,7 @@ namespace Mono.Xml.Native
 				Initialize (new FileStream (url, FileMode.Open));
 			}
 #else
-			Initialize (new FileStream (url, FileMode.Open));
+			Initialize (new FileStream (url, FileMode.Open, FileAccess.Read));
 #endif
 		}
 

+ 2 - 1
mcs/class/System.XML/System.Xml/XmlNamedNodeMap.cs

@@ -66,10 +66,11 @@ namespace System.Xml
 		{			
 			foreach (XmlNode node in nodeList)
 				if (node.Name == name) {
+					if (node.IsReadOnly)
+						throw new InvalidOperationException ("Cannot remove. This node is read only: " + name);
 					nodeList.Remove (node);
 					return node;
 				}
-			
 			return null;
 		}
 

+ 52 - 45
mcs/class/System.XML/System.Xml/XmlNode.cs

@@ -322,58 +322,65 @@ namespace System.Xml
 
 				// checking validity finished. then appending...
 
-				ownerDoc.onNodeInserting (newChild, this);
+				return insertBeforeIntern (newChild, refChild);
+			} 
+			else
+				throw new InvalidOperationException ();
+		}
+
+		internal XmlNode insertBeforeIntern (XmlNode newChild, XmlNode refChild)
+		{
+			XmlDocument ownerDoc = (NodeType == XmlNodeType.Document) ? (XmlDocument)this : OwnerDocument;
 
-				if(newChild.ParentNode != null)
-					newChild.ParentNode.RemoveChild (newChild);
+			ownerDoc.onNodeInserting (newChild, this);
 
-				if(newChild.NodeType == XmlNodeType.DocumentFragment) {
-					int x = newChild.ChildNodes.Count;
-					for(int i=0; i<x; i++) {
-						XmlNode n = newChild.ChildNodes [0];
-						this.InsertBefore (n, refChild);	// recursively invokes events. (It is compatible with MS implementation.)
-					}
+			if(newChild.ParentNode != null)
+				newChild.ParentNode.RemoveChild (newChild);
+
+			if(newChild.NodeType == XmlNodeType.DocumentFragment) {
+				int x = newChild.ChildNodes.Count;
+				for(int i=0; i<x; i++) {
+					XmlNode n = newChild.ChildNodes [0];
+					this.InsertBefore (n, refChild);	// recursively invokes events. (It is compatible with MS implementation.)
 				}
-				else {
-					XmlLinkedNode newLinkedChild = (XmlLinkedNode) newChild;
-					XmlLinkedNode lastLinkedChild = LastLinkedChild;
-
-					newLinkedChild.parentNode = this;
-
-					if(refChild == null) {
-						// append last, so:
-						// * set nextSibling of previous lastchild to newChild
-						// * set lastchild = newChild
-						// * set next of newChild to firstChild
-						if(LastLinkedChild != null) {
-							XmlLinkedNode formerFirst = FirstChild as XmlLinkedNode;
-							LastLinkedChild.NextLinkedSibling = newLinkedChild;
-							LastLinkedChild = newLinkedChild;
-							newLinkedChild.NextLinkedSibling = formerFirst;
-						}
-						else {
-							LastLinkedChild = newLinkedChild;
-							LastLinkedChild.NextLinkedSibling = newLinkedChild;	// FirstChild
-						}
+			}
+			else {
+				XmlLinkedNode newLinkedChild = (XmlLinkedNode) newChild;
+				XmlLinkedNode lastLinkedChild = LastLinkedChild;
+
+				newLinkedChild.parentNode = this;
+
+				if(refChild == null) {
+					// append last, so:
+					// * set nextSibling of previous lastchild to newChild
+					// * set lastchild = newChild
+					// * set next of newChild to firstChild
+					if(LastLinkedChild != null) {
+						XmlLinkedNode formerFirst = FirstChild as XmlLinkedNode;
+						LastLinkedChild.NextLinkedSibling = newLinkedChild;
+						LastLinkedChild = newLinkedChild;
+						newLinkedChild.NextLinkedSibling = formerFirst;
 					}
 					else {
-						// append not last, so:
-						// * if newchild is first, then set next of lastchild is newChild.
-						//   otherwise, set next of previous sibling to newChild
-						// * set next of newChild to refChild
-						XmlLinkedNode prev = refChild.PreviousSibling as XmlLinkedNode;
-						if(prev == null)
-							LastLinkedChild.NextLinkedSibling = newLinkedChild;
-						else
-							prev.NextLinkedSibling = newLinkedChild;
-						newLinkedChild.NextLinkedSibling = refChild as XmlLinkedNode;
+						LastLinkedChild = newLinkedChild;
+						LastLinkedChild.NextLinkedSibling = newLinkedChild;	// FirstChild
 					}
-					ownerDoc.onNodeInserted (newChild, newChild.ParentNode);
 				}
-				return newChild;
-			} 
-			else
-				throw new InvalidOperationException ();
+				else {
+					// append not last, so:
+					// * if newchild is first, then set next of lastchild is newChild.
+					//   otherwise, set next of previous sibling to newChild
+					// * set next of newChild to refChild
+					XmlLinkedNode prev = refChild.PreviousSibling as XmlLinkedNode;
+					if(prev == null)
+						LastLinkedChild.NextLinkedSibling = newLinkedChild;
+					else
+						prev.NextLinkedSibling = newLinkedChild;
+					newLinkedChild.NextLinkedSibling = refChild as XmlLinkedNode;
+				}
+				ownerDoc.onNodeInserted (newChild, newChild.ParentNode);
+			}
+			return newChild;
 		}
 
 		[MonoTODO]

+ 7 - 0
mcs/class/System.XML/System.Xml/XmlNotation.cs

@@ -20,6 +20,7 @@ namespace System.Xml
 		string publicId;
 		string systemId;
 		string prefix;
+		XmlLinkedNode lastChild;
 		
 		#endregion
 		
@@ -48,6 +49,12 @@ namespace System.Xml
 			get { return true; } // Notation nodes are always read-only
 		}
 
+		internal override XmlLinkedNode LastLinkedChild {
+			get { return lastChild; }
+
+			set { lastChild = value; }
+		}
+
 		public override string LocalName {
 			get { return localName; }
 		}

+ 281 - 0
mcs/class/System.XML/System.Xml/XmlParserInput.cs

@@ -0,0 +1,281 @@
+//
+// System.Xml.XmlParserInput
+//
+// Author:
+//	Atsushi Enomoto ([email protected])
+//
+//	(C)2003 Atsushi Enomoto
+//
+using System;
+using System.IO;
+using System.Text;
+using System.Xml;
+using System.Globalization;
+
+namespace Mono.Xml.Native
+{
+	public class XmlParserInput
+	{
+		#region ctor
+		public XmlParserInput (TextReader reader, string baseURI)
+			: this (reader, baseURI, 1, 1)
+		{
+		}
+
+		public XmlParserInput (TextReader reader, string baseURI, int line, int column)
+		{
+			this.reader = reader;
+
+			StreamReader sr = reader as StreamReader;
+			if (sr != null)
+				can_seek = sr.BaseStream.CanSeek;
+
+			this.line = line;
+			this.column = column;
+			this.baseURI = baseURI;
+		}
+		#endregion
+
+		#region Public Methods
+		// Read the next character and compare it against the
+		// specified character.
+		public void Expect (int expected)
+		{
+			int ch = ReadChar ();
+
+			if (ch != expected) {
+				throw ReaderError (
+					String.Format (
+						"expected '{0}' ({1:X}) but found '{2}' ({3:X})",
+						(char)expected,
+						expected,
+						(char)ch,
+						ch));
+			}
+		}
+
+		public void Expect (string expected)
+		{
+			int len = expected.Length;
+			for(int i=0; i< len; i++)
+				Expect (expected[i]);
+		}
+
+		public void InsertParameterEntityBuffer (string value)
+		{
+			this.peBuffer.Insert (0, value);
+		}
+
+		public int PeekChar ()
+		{
+			if (peBuffer.Length > 0)
+				return peBuffer [0];
+
+			if (can_seek)
+				return reader.Peek ();
+
+			if (has_peek)
+				return peek_char;
+
+			peek_char = reader.Read ();
+			has_peek = true;
+			return peek_char;
+		}
+
+		public int ReadChar ()
+		{
+			int ch;
+
+			if (peBuffer.Length > 0) {
+				ch = peBuffer [0];
+				peBuffer.Remove (0, 1);
+				// I decided not to add character to currentTag with respect to PERef value
+				return ch;
+			}
+
+			if (has_peek) {
+				ch = peek_char;
+				has_peek = false;
+			} else {
+				ch = reader.Read ();
+			}
+
+			if (ch == '\n') {
+				line++;
+				column = 1;
+			} else {
+				column++;
+			}
+			currentMarkup.Append ((char) ch);
+			return ch;
+		}
+#if FullTextParseSupport
+		// The reader is positioned on the first character after
+		// the leading '<!--'.
+		public void ReadComment ()
+		{
+			parsedValueStart = currentMarkup.Length;
+
+			while (PeekChar () != -1) {
+				int ch = ReadChar ();
+
+				if (ch == '-' && PeekChar () == '-') {
+					ReadChar ();
+
+					if (PeekChar () != '>')
+						throw ReaderError ("comments cannot contain '--'");
+
+					ReadChar ();
+					break;
+				}
+			}
+			parsedValueEnd = currentMarkup.Length - 3;
+		}
+
+		public void ReadName ()
+		{
+			ReadNameOrNmToken (false);
+		}
+
+		public void ReadNmToken ()
+		{
+			ReadNameOrNmToken (true);
+		}
+
+		// This method stop parse at '&' regardless of its kind.
+		public void ReadNonMarkupValue (bool start)
+		{
+			if (start)
+				parsedValueStart = currentMarkup.Length;
+
+			int ch = PeekChar ();
+
+			while (ch != '&' && ch != '<' && ch != -1) {
+				ReadChar ();
+				ch = PeekChar ();
+			}
+
+			parsedValueEnd = currentMarkup.Length;
+		}
+
+		public void ReadPEReference ()
+		{
+			Expect ('%');
+			ReadName ();
+			Expect (';');
+		}
+
+		public void ReadReference ()
+		{
+			Expect ('&');
+			ReadName ();
+			Expect (';');
+		}
+
+		public void SkipWhitespace ()
+		{
+			//FIXME: Should not skip if whitespaceHandling == WhiteSpaceHandling.None
+			while (XmlConstructs.IsSpace (PeekChar ()))
+				ReadChar ();
+		}
+#endif
+		#endregion
+
+		#region Public Properties
+		public string BaseURI {
+			get { return baseURI; }
+		}
+
+		public StringBuilder CurrentMarkup {
+			get { return this.currentMarkup; }
+		}
+
+		public int LineNumber {
+			get { return line; }
+		}
+
+		public int LinePosition {
+			get { return column; }
+		}
+		public string Name 
+		{
+			get {
+				return currentMarkup.ToString (parsedNameStart, parsedNameEnd - parsedNameStart);
+			}
+		}
+
+		public string Value {
+			get {
+				return currentMarkup.ToString (parsedValueStart, parsedValueEnd - parsedValueStart);
+			}
+		}
+		#endregion
+
+		#region Privates
+		private void ReadNameOrNmToken(bool isNameToken)
+		{
+			parsedNameStart = currentMarkup.Length;
+			if(isNameToken) {
+				if (!XmlConstructs.IsName ((char) PeekChar ()))
+					throw ReaderError ("a name did not start with a legal character " + PeekChar ());
+			}
+			else {
+				if (!XmlConstructs.IsNameStart ((char) PeekChar ()))
+					throw ReaderError ("a name did not start with a valid character " + PeekChar () + "(" + (char) PeekChar () + ")");
+			}
+
+			ReadChar ();
+
+			while (XmlConstructs.IsName (PeekChar ())) {
+				ReadChar ();
+			}
+
+			parsedNameEnd = currentMarkup.Length;
+		}
+
+		// Privates
+		TextReader reader;
+		bool can_seek;
+		bool has_peek;
+		int peek_char;
+		int line;
+		int column;
+		StringBuilder currentMarkup = new StringBuilder ();
+		int parsedNameStart;
+		int parsedNameEnd;
+		int parsedValueStart;
+		int parsedValueEnd;
+		StringBuilder peBuffer = new StringBuilder ();
+		string baseURI;
+
+		private int ParseCharReference (string name)
+		{
+			int ret = -1;
+			if (name.Length > 0 && name [0] == '#') {
+				if (name [1] == 'x')
+					ret = int.Parse (name.Substring (2, name.Length - 2), NumberStyles.None & NumberStyles.AllowHexSpecifier);
+				else
+					ret = int.Parse (name.Substring (1, name.Length - 1));
+			}
+			return ret;
+		}
+
+		private int ParseKnownEntityReference (string name)
+		{
+			switch (name) {
+			case "quot": return '"';
+			case "lt": return '<';
+			case "gt": return '>';
+			case "amp": return '&';
+			case "apos": return '\'';
+			}
+			return -1;
+		}
+
+		private XmlException ReaderError (string message)
+		{
+			return new XmlException (message, line, column);
+		}
+		#endregion
+	}
+}

Разлика између датотеке није приказан због своје велике величине
+ 1016 - 187
mcs/class/System.XML/System.Xml/XmlTextReader.cs


Неке датотеке нису приказане због велике количине промена