From: Lluis Sanchez Date: Tue, 11 Apr 2006 22:40:07 +0000 (-0000) Subject: 2006-04-11 Lluis Sanchez Gual X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=commitdiff_plain;h=00c2330e9a8913f66ba14bc6c55cd31a8bccae47;p=mono.git 2006-04-11 Lluis Sanchez Gual * 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 --- diff --git a/mcs/class/System.XML/System.Xml.Serialization/ChangeLog b/mcs/class/System.XML/System.Xml.Serialization/ChangeLog index 33457094d14..a386e9da6e4 100644 --- a/mcs/class/System.XML/System.Xml.Serialization/ChangeLog +++ b/mcs/class/System.XML/System.Xml.Serialization/ChangeLog @@ -1,3 +1,10 @@ +2006-04-11 Lluis Sanchez Gual + + * 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 * XmlReflectionImporter.cs: Throw NotSupportException instead of diff --git a/mcs/class/System.XML/System.Xml.Serialization/XmlSchemas.cs b/mcs/class/System.XML/System.Xml.Serialization/XmlSchemas.cs index e9968b25d2c..406a6ad3a79 100644 --- a/mcs/class/System.XML/System.Xml.Serialization/XmlSchemas.cs +++ b/mcs/class/System.XML/System.Xml.Serialization/XmlSchemas.cs @@ -128,8 +128,21 @@ namespace System.Xml.Serialization { } return null; } - else - return Find (schema, name, type); + else { + object fschema = Find (schema, name, type); +#if NET_2_0 + if (fschema == null) { + // still didn't find it + // (possibly table[name.Namespace] was overwritten in table due to duplicate "" keys), + // so look in all schemas (for consistiency with MS behaviour) + foreach (XmlSchema s in this) { + object ob = Find (s, name, type); + if (ob != null) return ob; + } + } +#endif + return fschema; + } } object Find (XmlSchema schema, XmlQualifiedName name, Type type) @@ -191,6 +204,10 @@ namespace System.Xml.Serialization { { string ns = ((XmlSchema) value).TargetNamespace; if (ns == null) ns = ""; +#if ONLY_1_1 + if (table.Contains (ns)) + throw new InvalidOperationException ("A schema with the namespace '" + ns + "' has already been added."); +#endif table [ns] = value; }