diff options
author | Atsushi Eno <atsushieno@gmail.com> | 2006-01-06 18:58:52 +0300 |
---|---|---|
committer | Atsushi Eno <atsushieno@gmail.com> | 2006-01-06 18:58:52 +0300 |
commit | df9a592c8c646fdbec7b4f406fb56e4c3edc5fe5 (patch) | |
tree | 6575411604f63279441e089b739edd281a3f0074 /mcs/class/System.XML | |
parent | 02e768a2768bac9494540637c5f063e861d5aa74 (diff) |
2006-01-06 Atsushi Enomoto <atsushi@ximian.com>
* 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
Diffstat (limited to 'mcs/class/System.XML')
4 files changed, 56 insertions, 5 deletions
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,5 +1,10 @@ 2006-01-06 Atsushi Enomoto <atsushi@ximian.com> + * XmlSchemaSet.cs : Add() rollbacks IsCompiled to false. + Global components are not added when Add() is called. + +2006-01-06 Atsushi Enomoto <atsushi@ximian.com> + * XmlSchemaSet.cs : reverted previous fix; it broke inclusions. 2006-01-06 Atsushi Enomoto <atsushi@ximian.com> 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,5 +1,10 @@ 2006-01-06 Atsushi Enomoto <atsushi@ximian.com> + * XmlSchemaSetTests.cs : added AddRollbackIsCompiled(); Add() changes + IsCompiled to false. + +2006-01-06 Atsushi Enomoto <atsushi@ximian.com> + * XmlSchemaSetTests.cs : reverted the patch, thus restore [Ignore]. 2006-01-06 Atsushi Enomoto <atsushi@ximian.com> 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 |