2006-04-11 Lluis Sanchez Gual <lluis@novell.com>
authorLluis Sanchez <lluis@novell.com>
Tue, 11 Apr 2006 22:40:07 +0000 (22:40 -0000)
committerLluis Sanchez <lluis@novell.com>
Tue, 11 Apr 2006 22:40:07 +0000 (22:40 -0000)
* XmlSchemas.cs: In 1.1, don't allow adding two schemas
with the same namespaces. This is allowed in 2.0. Fixed
the Find() method to cope with this case. Based on a patch
by David Jung.

svn path=/trunk/mcs/; revision=59384

mcs/class/System.XML/System.Xml.Serialization/ChangeLog
mcs/class/System.XML/System.Xml.Serialization/XmlSchemas.cs

index 33457094d147acfbc8b669e39d6533946e856c06..a386e9da6e4bdd74c617af12f40a3d3d41fe6a4d 100644 (file)
@@ -1,3 +1,10 @@
+2006-04-11  Lluis Sanchez Gual  <lluis@novell.com>
+
+       * XmlSchemas.cs: In 1.1, don't allow adding two schemas
+       with the same namespaces. This is allowed in 2.0. Fixed
+       the Find() method to cope with this case. Based on a patch
+       by David Jung.
+
 2006-03-22  Gert Driesen  <drieseng@users.sourceforge.net>
 
        * XmlReflectionImporter.cs: Throw NotSupportException instead of
index e9968b25d2cc3b16e3032db5068235648f143897..406a6ad3a79bcce6d187edc65171e30a100d70f0 100644 (file)
@@ -128,8 +128,21 @@ namespace System.Xml.Serialization {
                                }\r
                                return null;\r
                        }\r
-                       else\r
-                               return Find (schema, name, type);\r
+                       else {\r
+                               object fschema = Find (schema, name, type);\r
+#if NET_2_0\r
+                               if (fschema == null) {\r
+                                       // still didn't find it\r
+                                       // (possibly table[name.Namespace] was overwritten in table due to duplicate "" keys),\r
+                                       // so look in all schemas (for consistiency with MS behaviour)\r
+                                       foreach (XmlSchema s in this) {\r
+                                               object ob = Find (s, name, type);\r
+                                               if (ob != null) return ob;\r
+                                       }\r
+                               }\r
+#endif\r
+                               return fschema;\r
+                       }\r
                }\r
 \r
                object Find (XmlSchema schema, XmlQualifiedName name, Type type)\r
@@ -191,6 +204,10 @@ namespace System.Xml.Serialization {
                {\r
                        string ns = ((XmlSchema) value).TargetNamespace;\r
                        if (ns == null) ns = "";\r
+#if ONLY_1_1\r
+                       if (table.Contains (ns))\r
+                               throw new InvalidOperationException ("A schema with the namespace '" + ns + "' has already been added.");\r
+#endif\r
                        table [ns] = value;\r
                }\r
 \r