Browse Source

2006-01-06 Atsushi Enomoto <[email protected]>

	* XmlSchemaSet.cs : Add() needs (consistent) namespace duplicate check.

	* XmlSchemaSetTests.cs : re-enabled test for Add() which was
	  inconsistent in beta versions.


svn path=/trunk/mcs/; revision=55145
Atsushi Eno 20 years ago
parent
commit
fd4622ca84

+ 4 - 0
mcs/class/System.XML/System.Xml.Schema/ChangeLog

@@ -1,3 +1,7 @@
+2006-01-06  Atsushi Enomoto <[email protected]>
+
+	* XmlSchemaSet.cs : Add() needs (consistent) namespace duplicate check.
+
 2006-01-06  Atsushi Enomoto <[email protected]>
 
 	* XmlSchemaSimpleTypeRestriction.cs : maxLength and minLength were

+ 13 - 5
mcs/class/System.XML/System.Xml.Schema/XmlSchemaSet.cs

@@ -158,9 +158,17 @@ namespace System.Xml.Schema
 			}
 		}
 
-		[MonoTODO ("It has weird namespace duplication check that is different from Add(XmlSchema).")]
+		void CheckDuplicateNS (string targetNamespace)
+		{
+			if (Schemas (GetSafeNs (targetNamespace)).Count > 0)
+				throw new ArgumentException (String.Format ("Corresponding schema for namespace '{0}' has been already added.", targetNamespace));
+		}
+
 		public XmlSchema Add (string targetNamespace, XmlReader reader)
 		{
+			// don't check it here; check only in-use TargetNamespace
+			//CheckDuplicateNS (targetNamespace);
+
 			XmlSchema schema = XmlSchema.Read (reader, handler);
 			if (targetNamespace != null
 				&& targetNamespace.Length > 0)
@@ -169,7 +177,6 @@ namespace System.Xml.Schema
 			return schema;
 		}
 
-		[MonoTODO ("Check the exact behavior when namespaces are in conflict (but it would be preferable to wait for 2.0 RTM).")]
 		public void Add (XmlSchemaSet schemaSet)
 		{
 			ArrayList al = new ArrayList ();
@@ -183,10 +190,12 @@ namespace System.Xml.Schema
 				Add (schema);
 		}
 
-		[MonoTODO ("We need to research more about the expected behavior")]
 		public XmlSchema Add (XmlSchema schema)
 		{
-			schemas.Add (schema);
+			if (!schemas.Contains (schema)) {
+				CheckDuplicateNS (schema.TargetNamespace);
+				schemas.Add (schema);
+			}
 			AddGlobalComponents (schema);
 			return schema;
 		}
@@ -327,7 +336,6 @@ namespace System.Xml.Schema
 			return schemas;
 		}
 
-		[MonoTODO]
 		public ICollection Schemas (string targetNamespace)
 		{
 			targetNamespace = GetSafeNs (targetNamespace);

+ 5 - 0
mcs/class/System.XML/Test/System.Xml.Schema/ChangeLog

@@ -1,3 +1,8 @@
+2006-01-06  Atsushi Enomoto <[email protected]>
+
+	* XmlSchemaSetTests.cs : re-enabled test for Add() which was
+	  inconsistent in beta versions.
+
 2005-12-08  Atsushi Enomoto <[email protected]>
 
 	* XmlSchemaSetTests.cs : added set_CompilationSettings tests.

+ 1 - 1
mcs/class/System.XML/Test/System.Xml.Schema/XmlSchemaSetTests.cs

@@ -56,7 +56,7 @@ namespace MonoTests.System.Xml
 		}
 
 		[Test]
-		[Ignore ("This behavior might be changed, since Add(XmlSchema) does not throw any exceptions, while this does.")]
+		//[Ignore ("This behavior might be changed, since Add(XmlSchema) does not throw any exceptions, while this does.")]
 		[ExpectedException (typeof (ArgumentException))]
 		public void AddTwice ()
 		{