From fd4622ca847010ec7ba0752f0bf7bfc63502adea Mon Sep 17 00:00:00 2001 From: Atsushi Eno Date: Fri, 6 Jan 2006 12:24:46 +0000 Subject: 2006-01-06 Atsushi Enomoto * 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 --- mcs/class/System.XML/System.Xml.Schema/ChangeLog | 4 ++++ mcs/class/System.XML/System.Xml.Schema/XmlSchemaSet.cs | 18 +++++++++++++----- mcs/class/System.XML/Test/System.Xml.Schema/ChangeLog | 5 +++++ .../Test/System.Xml.Schema/XmlSchemaSetTests.cs | 2 +- 4 files changed, 23 insertions(+), 6 deletions(-) (limited to 'mcs/class/System.XML') diff --git a/mcs/class/System.XML/System.Xml.Schema/ChangeLog b/mcs/class/System.XML/System.Xml.Schema/ChangeLog index 1969b4b2ca6..99f5fe328ef 100644 --- a/mcs/class/System.XML/System.Xml.Schema/ChangeLog +++ b/mcs/class/System.XML/System.Xml.Schema/ChangeLog @@ -1,3 +1,7 @@ +2006-01-06 Atsushi Enomoto + + * XmlSchemaSet.cs : Add() needs (consistent) namespace duplicate check. + 2006-01-06 Atsushi Enomoto * XmlSchemaSimpleTypeRestriction.cs : maxLength and minLength were diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaSet.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaSet.cs index 8b39ba965a3..d194f3bd879 100644 --- a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaSet.cs +++ b/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); diff --git a/mcs/class/System.XML/Test/System.Xml.Schema/ChangeLog b/mcs/class/System.XML/Test/System.Xml.Schema/ChangeLog index 005d42464b9..9aa293571cf 100644 --- a/mcs/class/System.XML/Test/System.Xml.Schema/ChangeLog +++ b/mcs/class/System.XML/Test/System.Xml.Schema/ChangeLog @@ -1,3 +1,8 @@ +2006-01-06 Atsushi Enomoto + + * XmlSchemaSetTests.cs : re-enabled test for Add() which was + inconsistent in beta versions. + 2005-12-08 Atsushi Enomoto * XmlSchemaSetTests.cs : added set_CompilationSettings tests. diff --git a/mcs/class/System.XML/Test/System.Xml.Schema/XmlSchemaSetTests.cs b/mcs/class/System.XML/Test/System.Xml.Schema/XmlSchemaSetTests.cs index d8d006fb860..27ba7b47646 100644 --- a/mcs/class/System.XML/Test/System.Xml.Schema/XmlSchemaSetTests.cs +++ b/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 () { -- cgit v1.2.3