* roottypes.cs: Rename from tree.cs.
[mono.git] / mcs / class / System.XML / System.Xml.Schema / XmlSchemaCollection.cs
old mode 100755 (executable)
new mode 100644 (file)
index 4f7aa31..e8721ec
@@ -56,6 +56,7 @@ namespace System.Xml.Schema
                public XmlSchemaCollection (XmlNameTable nameTable)
                        : this (new XmlSchemaSet (nameTable))
                {
+                       schemaSet.ValidationEventHandler += new ValidationEventHandler (OnValidationError);
                }
 
                internal XmlSchemaCollection (XmlSchemaSet schemaSet)
@@ -105,7 +106,7 @@ namespace System.Xml.Schema
 #endif
                {
                        XmlSchema schema = XmlSchema.Read (reader, ValidationEventHandler);
-                       schema.Compile (ValidationEventHandler, schemaSet, resolver);
+                       schema.CompileSubset (ValidationEventHandler, schemaSet, resolver);
                        lock (schemaSet) {
                                return schemaSet.Add (schema);
                        }
@@ -130,12 +131,11 @@ namespace System.Xml.Schema
 
                        // XmlSchemaCollection.Add() compiles, while XmlSchemaSet.Add() does not
                        if (!schema.IsCompiled)
-                               schema.Compile (ValidationEventHandler, schemaSet, resolver);
+                               schema.CompileSubset (ValidationEventHandler, schemaSet, resolver);
                        // compilation error -> returns null (and don't add to the collection).
                        if (!schema.IsCompiled)
                                return null;
 
-                       string ns = GetSafeNs (schema.TargetNamespace);
                        lock (schemaSet) {
                                // consider imported schemas.
                                schemaSet.Add (schema.Schemas);
@@ -143,11 +143,6 @@ namespace System.Xml.Schema
                        }
                }
 
-               private string GetSafeNs (string ns)
-               {
-                       return ns != null ? ns : String.Empty;
-               }
-
                public void Add (XmlSchemaCollection schema)
                {
                        if (schema == null)
@@ -181,7 +176,12 @@ namespace System.Xml.Schema
 
                public XmlSchemaCollectionEnumerator GetEnumerator ()
                {
-                       return new XmlSchemaCollectionEnumerator (this);
+                        // The actual collection is schemaSet.Schemas()
+                       return new XmlSchemaCollectionEnumerator(schemaSet.Schemas());
+               }
+
+               int ICollection.Count {
+                       get { return Count; }
                }
 
                // interface Methods
@@ -207,7 +207,7 @@ namespace System.Xml.Schema
                        get { return this; }
                }
 
-               internal void OnValidationError (object o, ValidationEventArgs e)
+               void OnValidationError (object o, ValidationEventArgs e)
                {
                        if (ValidationEventHandler != null)
                                ValidationEventHandler (o, e);