From df9a592c8c646fdbec7b4f406fb56e4c3edc5fe5 Mon Sep 17 00:00:00 2001 From: Atsushi Eno Date: Fri, 6 Jan 2006 15:58:52 +0000 Subject: 2006-01-06 Atsushi Enomoto * XmlSchemaSet.cs : Add() rollbacks IsCompiled to false. Global components are not added when Add() is called. * XmlSchemaSetTests.cs : added AddRollbackIsCompiled(); Add() changes IsCompiled to false. svn path=/trunk/mcs/; revision=55151 --- mcs/class/System.XML/System.Xml.Schema/ChangeLog | 5 ++++ .../System.XML/System.Xml.Schema/XmlSchemaSet.cs | 16 ++++++---- .../System.XML/Test/System.Xml.Schema/ChangeLog | 5 ++++ .../Test/System.Xml.Schema/XmlSchemaSetTests.cs | 35 ++++++++++++++++++++++ 4 files changed, 56 insertions(+), 5 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 e6955d0b222..17cefced3de 100644 --- a/mcs/class/System.XML/System.Xml.Schema/ChangeLog +++ b/mcs/class/System.XML/System.Xml.Schema/ChangeLog @@ -1,3 +1,8 @@ +2006-01-06 Atsushi Enomoto + + * XmlSchemaSet.cs : Add() rollbacks IsCompiled to false. + Global components are not added when Add() is called. + 2006-01-06 Atsushi Enomoto * XmlSchemaSet.cs : reverted previous fix; it broke inclusions. diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaSet.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaSet.cs index 8b39ba965a3..76561d2deec 100644 --- a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaSet.cs +++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaSet.cs @@ -176,8 +176,6 @@ namespace System.Xml.Schema foreach (XmlSchema schema in schemaSet.schemas) { if (!schemas.Contains (schema)) al.Add (schema); - else - AddGlobalComponents (schema); } foreach (XmlSchema schema in al) Add (schema); @@ -187,7 +185,7 @@ namespace System.Xml.Schema public XmlSchema Add (XmlSchema schema) { schemas.Add (schema); - AddGlobalComponents (schema); + ResetCompile (); return schema; } @@ -280,12 +278,16 @@ namespace System.Xml.Schema if (!schema.IsCompiled) schema.Compile (handler, this, xmlResolver); schemas.Remove (schema); + ResetCompile (); + return schema; + } + + void ResetCompile () + { isCompiled = false; ClearGlobalComponents (); - return schema; } - [MonoTODO ("Check exact behavior")] public bool RemoveRecursive (XmlSchema schema) { if (schema == null) @@ -296,6 +298,10 @@ namespace System.Xml.Schema return false; al.Remove (schema); schemas.Remove (schema); + + if (!IsCompiled) + return true; + ClearGlobalComponents (); foreach (XmlSchema s in al) { if (s.IsCompiled) diff --git a/mcs/class/System.XML/Test/System.Xml.Schema/ChangeLog b/mcs/class/System.XML/Test/System.Xml.Schema/ChangeLog index 0924fe928d0..b40a0c2b464 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 : added AddRollbackIsCompiled(); Add() changes + IsCompiled to false. + 2006-01-06 Atsushi Enomoto * XmlSchemaSetTests.cs : reverted the patch, thus restore [Ignore]. 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..56a066c6760 100644 --- a/mcs/class/System.XML/Test/System.Xml.Schema/XmlSchemaSetTests.cs +++ b/mcs/class/System.XML/Test/System.Xml.Schema/XmlSchemaSetTests.cs @@ -95,6 +95,41 @@ namespace MonoTests.System.Xml xss.Compile (); } + + [Test] + public void AddRollbackIsCompiled () + { + XmlSchemaSet ss = new XmlSchemaSet (); + ss.Add (new XmlSchema ()); + ss.Compile (); + Assert.IsTrue (ss.IsCompiled, "#1"); + XmlSchema sc = new XmlSchema (); // compiled one + sc.Compile (null); + ss.Add (sc); + Assert.IsFalse (ss.IsCompiled, "#2"); + ss.Add (new XmlSchema ()); // not-compiled one + Assert.IsFalse (ss.IsCompiled, "#3"); + XmlSchema s; + + s = new XmlSchema (); + s.TargetNamespace = "urn:foo"; + XmlSchemaElement el; + el = new XmlSchemaElement (); + el.Name = "root"; + s.Items.Add (el); + ss.Add (s); + + s = new XmlSchema (); + s.TargetNamespace = "urn:foo"; + el = new XmlSchemaElement (); + el.Name = "foo"; + s.Items.Add (el); + ss.Add (s); + ss.Compile (); + Assert.IsTrue (ss.IsCompiled, "#4"); + ss.RemoveRecursive (s); + Assert.IsTrue (ss.IsCompiled, "#5"); + } } } #endif -- cgit v1.2.3