Răsfoiți Sursa

2004-07-09 Atsushi Enomoto <[email protected]>

	* XmlAttributeCollection.cs : In .net 2.0, it became sealed class.
	* IXmlDataEvidence.cs : not "Evidences" but "Evidence".
	* XmlInputStream.cs : new csc rejected implicit int->char cast.
	* XmlNamespaceManager.cs : In net_2_0, LookupNamespace(string) and
	  LookupPrefix(string) does not require argument string as atomized.
	  Added HasNamespace (string, bool).
	* XmlReader.cs : Added Settings and SchemaInfo properties.
	* XmlReaderSettings.cs : Added NameTable. Throw XmlException when
	  attempt to set Schemas.
	* XmlTextReader.cs : Fixed "Evidences" to "Evidence". new csc rejected
	  implicit int->char cast.
	* XmlValidatingReader.cs : Fixed "Evidences" to "Evidence".

svn path=/trunk/mcs/; revision=30919
Atsushi Eno 21 ani în urmă
părinte
comite
93314cd44c

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

@@ -1,3 +1,23 @@
+2004-07-09  Atsushi Enomoto  <[email protected]>
+
+	* XmlAttributeCollection.cs : In .net 2.0, it became sealed class.
+	* IXmlDataEvidence.cs : not "Evidences" but "Evidence".
+	* XmlInputStream.cs : new csc rejected implicit int->char cast.
+	* XmlNamespaceManager.cs : In net_2_0, LookupNamespace(string) and
+	  LookupPrefix(string) does not require argument string as atomized.
+	  Added HasNamespace (string, bool).
+	* XmlReader.cs : Added Settings and SchemaInfo properties.
+	* XmlReaderSettings.cs : Added NameTable. Throw XmlException when
+	  attempt to set Schemas.
+	* XmlTextReader.cs : Fixed "Evidences" to "Evidence". new csc rejected
+	  implicit int->char cast.
+	* XmlValidatingReader.cs : Fixed "Evidences" to "Evidence".
+
+2004-06-27  Atsushi Enomoto  <[email protected]>
+
+	* XmlDocument.cs:
+	  Close XmlReader only when it is created. This fixes bug #60809.
+
 2004-06-18  Atsushi Enomoto <[email protected]>
 
 	* DTDObjectModel.cs, DTDReader.cs, XmlConvert.cs, XmlDocument.cs,

+ 1 - 1
mcs/class/System.XML/System.Xml/IXmlDataEvidence.cs

@@ -35,7 +35,7 @@ namespace System.Xml
 
 	public interface IXmlDataEvidence
 	{
-		Evidence[] Evidences { get; } 
+		Evidence[] Evidence { get; } 
 	}
 }
 #endif

+ 44 - 1
mcs/class/System.XML/System.Xml/XmlAttributeCollection.cs

@@ -36,7 +36,11 @@ using Mono.Xml;
 
 namespace System.Xml
 {
+#if NET_2_0
+	public sealed class XmlAttributeCollection : XmlNamedNodeMap, ICollection
+#else
 	public class XmlAttributeCollection : XmlNamedNodeMap, ICollection
+#endif
 	{
 		XmlElement ownerElement;
 		XmlDocument ownerDocument;
@@ -58,21 +62,33 @@ namespace System.Xml
 		}
 
 		[System.Runtime.CompilerServices.IndexerName ("ItemOf")]
+#if NET_2_0
+		public XmlAttribute this [string name] {
+#else
 		public virtual XmlAttribute this [string name] {
+#endif
 			get {
 				return (XmlAttribute) GetNamedItem (name);
 			}
 		}
 
 		[System.Runtime.CompilerServices.IndexerName ("ItemOf")]
+#if NET_2_0
+		public XmlAttribute this [int i] {
+#else
 		public virtual XmlAttribute this [int i] {
+#endif
 			get {
 				return (XmlAttribute) Nodes [i];
 			}
 		}
 
 		[System.Runtime.CompilerServices.IndexerName ("ItemOf")]
+#if NET_2_0
+		public XmlAttribute this [string localName, string namespaceURI] {
+#else
 		public virtual XmlAttribute this [string localName, string namespaceURI] {
+#endif
 			get {
 				return (XmlAttribute) GetNamedItem (localName, namespaceURI);
 			}
@@ -82,8 +98,11 @@ namespace System.Xml
 			get { return this; }
 		}
 
-		
+#if NET_2_0
+		public XmlAttribute Append (XmlAttribute node) 
+#else
 		public virtual XmlAttribute Append (XmlAttribute node) 
+#endif
 		{
 			XmlNode xmlNode = this.SetNamedItem (node);
 			return node;
@@ -102,7 +121,11 @@ namespace System.Xml
 			array.CopyTo (Nodes.ToArray (typeof(XmlAttribute)), index);
 		}
 
+#if NET_2_0
+		public XmlAttribute InsertAfter (XmlAttribute newNode, XmlAttribute refNode)
+#else
 		public virtual XmlAttribute InsertAfter (XmlAttribute newNode, XmlAttribute refNode)
+#endif
 		{
 			if (refNode == null) {
 				if (Nodes.Count == 0)
@@ -117,7 +140,11 @@ namespace System.Xml
 			throw new ArgumentException ("refNode not found in this collection.");
 		}
 
+#if NET_2_0
+		public XmlAttribute InsertBefore (XmlAttribute newNode, XmlAttribute refNode)
+#else
 		public virtual XmlAttribute InsertBefore (XmlAttribute newNode, XmlAttribute refNode)
+#endif
 		{
 			if (newNode.OwnerDocument != ownerDocument)
 				throw new ArgumentException ("different document created this newNode.");
@@ -143,12 +170,20 @@ namespace System.Xml
 			return newNode;
 		}
 
+#if NET_2_0
+		public XmlAttribute Prepend (XmlAttribute node) 
+#else
 		public virtual XmlAttribute Prepend (XmlAttribute node) 
+#endif
 		{
 			return this.InsertAfter (node, null);
 		}
 
+#if NET_2_0
+		public XmlAttribute Remove (XmlAttribute node) 
+#else
 		public virtual XmlAttribute Remove (XmlAttribute node) 
+#endif
 		{
 			if (IsReadOnly)
 				throw new ArgumentException ("This attribute collection is read-only.");
@@ -187,7 +222,11 @@ namespace System.Xml
 			return retAttr;
 		}
 
+#if NET_2_0
+		public void RemoveAll () 
+#else
 		public virtual void RemoveAll () 
+#endif
 		{
 			int current = 0;
 			while (current < Count) {
@@ -199,7 +238,11 @@ namespace System.Xml
 			}
 		}
 
+#if NET_2_0
+		public XmlAttribute RemoveAt (int i) 
+#else
 		public virtual XmlAttribute RemoveAt (int i) 
+#endif
 		{
 			if(Nodes.Count <= i)
 				return null;

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

@@ -201,7 +201,7 @@ namespace System.Xml
 			int c;
 			while (true) {
 				c = ReadByteSpecial ();
-				switch (c) {
+				switch ((char) c) {
 				case '\r': goto case ' ';
 				case '\n': goto case ' ';
 				case '\t': goto case ' ';

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

@@ -4,9 +4,11 @@
 // Authors:
 //   Jason Diamond ([email protected])
 //   Ben Maurer ([email protected])
+//   Atsushi Enomoto ([email protected])
 //
 // (C) 2001 Jason Diamond  http://injektilo.org/
 // (C) 2003 Ben Maurer
+// (C) 2004 Novell Inc.
 //
 
 //
@@ -209,6 +211,15 @@ namespace System.Xml
 #endif
 
 		public virtual bool HasNamespace (string prefix)
+		{
+			return HasNamespace (prefix, false);
+		}
+		
+#if NET_2_0
+		public virtual bool HasNamespace (string prefix, bool atomizedNames)
+#else
+		internal virtual bool HasNamespace (string prefix, bool atomizedNames)
+#endif
 		{
 			if (prefix == null || count == 0)
 				return false;
@@ -223,7 +234,11 @@ namespace System.Xml
 
 		public virtual string LookupNamespace (string prefix)
 		{
+#if NET_2_0
+			return LookupNamespace (prefix, false);
+#else
 			return LookupNamespace (prefix, true);
+#endif
 		}
 
 #if NET_2_0
@@ -253,7 +268,11 @@ namespace System.Xml
 
 		public virtual string LookupPrefix (string uri)
 		{
+#if NET_2_0
+			return LookupPrefix (uri, false);
+#else
 			return LookupPrefix (uri, true);
+#endif
 		}
 
 		private bool CompareString (string s1, string s2, bool atomizedNames)

+ 19 - 1
mcs/class/System.XML/System.Xml/XmlReader.cs

@@ -35,6 +35,8 @@ using System.IO;
 using System.Security.Policy;
 using System.Text;
 
+using System.Xml.Schema; // only required for NET_2_0 (SchemaInfo)
+
 namespace System.Xml
 {
 #if NET_2_0
@@ -45,6 +47,9 @@ namespace System.Xml
 	{
 		private StringBuilder readStringBuffer;
 		private Evidence [] evidences;
+#if NET_2_0
+		private XmlReaderSettings settings;
+#endif
 
 		#region Constructor
 
@@ -71,7 +76,7 @@ namespace System.Xml
 
 #if NET_2_0
 		[MonoTODO]
-		public virtual Evidence [] Evidences {
+		public virtual Evidence [] Evidence {
 			get { return evidences; }
 		}
 #endif
@@ -112,6 +117,19 @@ namespace System.Xml
 
 		public abstract ReadState ReadState { get; }
 
+#if NET_2_0
+		[MonoTODO]
+		public virtual IXmlSchemaInfo SchemaInfo {
+			get {
+				throw new NotImplementedException ();
+			}
+		}
+
+		public virtual XmlReaderSettings Settings {
+			get { return settings; }
+		}
+#endif
+
 		public abstract string Value { get; }
 
 		public abstract string XmlLang { get; }

+ 13 - 2
mcs/class/System.XML/System.Xml/XmlReaderSettings.cs

@@ -53,6 +53,7 @@ namespace System.Xml
 		private int lineNumberOffset;
 		private int linePositionOffset;
 		private bool prohibitDtd;
+		private XmlNameTable nameTable;
 		private XmlSchemaSet schemas;
 		private bool xsdValidate;
 
@@ -81,6 +82,7 @@ namespace System.Xml
 			prohibitDtd = org.prohibitDtd;
 			schemas = org.schemas;
 			xsdValidate = org.xsdValidate;
+			nameTable = org.NameTable;
 		}
 
 		public event ValidationEventHandler ValidationEventHandler;
@@ -185,10 +187,19 @@ namespace System.Xml
 			set { prohibitDtd = value; }
 		}
 
-		[MonoTODO ("Can set null value?")]
+		// LAMESPEC: MSDN documentation says "An empty XmlNameTable
+		// object" for default value, but XmlNameTable cannot be
+		// instantiate. It actually returns null by default.
+		public XmlNameTable NameTable {
+			get { return nameTable; }
+		}
+
+		// LAMESPEC: Apparently, this property should not have a setter.
 		public XmlSchemaSet Schemas {
 			get { return schemas; }
-			set { schemas = value; }
+			set {
+				throw new XmlException ("XmlReaderSettings.Schemas is read-only and cannot be set.");
+			}
 		}
 
 		public bool XsdValidate {

+ 26 - 23
mcs/class/System.XML/System.Xml/XmlTextReader.cs

@@ -188,8 +188,8 @@ namespace System.Xml
 
 #if NET_2_0
 		[MonoTODO]
-		public override Evidence [] Evidences {
-			get { return base.Evidences; }
+		public override Evidence [] Evidence {
+			get { return base.Evidence; }
 		}
 #endif
 
@@ -1189,24 +1189,8 @@ namespace System.Xml
 			if (returnEntityReference)
 				SetEntityReferenceProperties ();
 			else {
-    				switch (PeekChar ()) {
-				case '<':
-					ReadChar ();
-					ReadTag ();
-					break;
-				case '\r': goto case ' ';
-				case '\n': goto case ' ';
-				case '\t': goto case ' ';
-				case ' ':
-					if (whitespaceHandling == WhitespaceHandling.All ||
-						whitespaceHandling == WhitespaceHandling.Significant)
-						ReadWhitespace ();
-					else {
-						SkipWhitespace ();
-						return ReadContent ();
-					}
-					break;
-				case -1:
+				int c = PeekChar ();
+				if (c == -1) {
 					readState = ReadState.EndOfFile;
 					ClearValueBuffer ();
 					SetProperties (
@@ -1220,9 +1204,28 @@ namespace System.Xml
 						throw new XmlException ("unexpected end of file. Current depth is " + depth);
 
 					return false;
-				default:
-					ReadText (true);
-					break;
+				} else {
+ 	   				switch ((char) c) {
+					case '<':
+						ReadChar ();
+						ReadTag ();
+						break;
+					case '\r': goto case ' ';
+					case '\n': goto case ' ';
+					case '\t': goto case ' ';
+					case ' ':
+						if (whitespaceHandling == WhitespaceHandling.All ||
+							whitespaceHandling == WhitespaceHandling.Significant)
+							ReadWhitespace ();
+						else {
+							SkipWhitespace ();
+							return ReadContent ();
+						}
+						break;
+					default:
+						ReadText (true);
+						break;
+					}
 				}
 			}
 			return this.ReadState != ReadState.EndOfFile;

+ 1 - 1
mcs/class/System.XML/System.Xml/XmlValidatingReader.cs

@@ -121,7 +121,7 @@ namespace System.Xml {
 
 #if NET_2_0
 		[MonoTODO]
-		public override Evidence [] Evidences {
+		public override Evidence [] Evidence {
 			get { throw new NotImplementedException ();
 			}
 		}