svn path=/branches/mono-1-1-9/mcs/; revision=51207
[mono.git] / mcs / class / System.XML / Mono.Xml.Schema / XsdValidatingReader.cs
index 51cbbcb98c080bd289bcf1fbf7adfac7cbafd4c7..4355366e729abcd798ee4662d23eec983cd670ad 100644 (file)
@@ -29,6 +29,9 @@
 //
 using System;
 using System.Collections;
+#if NET_2_0
+using System.Collections.Generic;
+#endif
 using System.Collections.Specialized;
 using System.IO;
 using System.Text;
@@ -192,7 +195,12 @@ namespace Mono.Xml.Schema
                        }
                }
 
-               IDictionary IXmlNamespaceResolver.GetNamespacesInScope (XmlNamespaceScope scope)
+#if NET_2_0
+               IDictionary<string, string> 
+#else
+               IDictionary
+#endif
+               IXmlNamespaceResolver.GetNamespacesInScope (XmlNamespaceScope scope)
                {
                        IXmlNamespaceResolver resolver = reader as IXmlNamespaceResolver;
                        if (resolver == null)
@@ -201,16 +209,11 @@ namespace Mono.Xml.Schema
                }
 
                string IXmlNamespaceResolver.LookupPrefix (string ns)
-               {
-                       return ((IXmlNamespaceResolver) this).LookupPrefix (ns, false);
-               }
-
-               string IXmlNamespaceResolver.LookupPrefix (string ns, bool atomizedNames)
                {
                        IXmlNamespaceResolver resolver = reader as IXmlNamespaceResolver;
                        if (resolver == null)
                                throw new NotSupportedException ("The input XmlReader does not implement IXmlNamespaceResolver and thus this validating reader cannot execute namespace prefix lookup.");
-                       return resolver.LookupPrefix (ns, atomizedNames);
+                       return resolver.LookupPrefix (ns);
                }
 
                // It is used only for independent XmlReader use, not for XmlValidatingReader.
@@ -228,44 +231,6 @@ namespace Mono.Xml.Schema
                        return o;
                }
                
-               private object ReadTypedValueCore ()
-               {
-                       XsDatatype dt = SchemaType as XsDatatype;
-                       SimpleType st = SchemaType as SimpleType;
-                       if (st != null)
-                               dt = st.Datatype;
-                       if (dt == null)
-                               return null;
-
-                       switch (NodeType) {
-                       case XmlNodeType.Element:
-                               if (IsEmptyElement)
-                                       return null;
-
-                               storedCharacters.Length = 0;
-                               bool loop = true;
-                               do {
-                                       Read ();
-                                       switch (NodeType) {
-                                       case XmlNodeType.SignificantWhitespace:
-                                       case XmlNodeType.Text:
-                                       case XmlNodeType.CDATA:
-                                               storedCharacters.Append (Value);
-                                               break;
-                                       case XmlNodeType.Comment:
-                                               break;
-                                       default:
-                                               loop = false;
-                                               break;
-                                       }
-                               } while (loop && !EOF && ReadState == ReadState.Interactive);
-                               return dt.ParseValue (storedCharacters.ToString (), NameTable, ParserContext.NamespaceManager);
-                       case XmlNodeType.Attribute:
-                               return dt.ParseValue (Value, NameTable, ParserContext.NamespaceManager);
-                       }
-                       return null;
-               }
-
                // Public Overriden Properties
 
                public override int AttributeCount {
@@ -1356,15 +1321,6 @@ namespace Mono.Xml.Schema
                        return reader.LookupNamespace (prefix);
                }
 
-               string IXmlNamespaceResolver.LookupNamespace (string prefix, bool atomizedNames)
-               {
-                       IXmlNamespaceResolver res = reader as IXmlNamespaceResolver;
-                       if (res != null)
-                               return res.LookupNamespace (prefix, atomizedNames);
-                       else
-                               return reader.LookupNamespace (prefix);
-               }
-
                public override void MoveToAttribute (int i)
                {
                        switch (reader.NodeType) {
@@ -1536,16 +1492,20 @@ namespace Mono.Xml.Schema
                                        schemaLocation = XsDatatype.FromName ("token", XmlSchema.Namespace).Normalize (schemaLocation);
                                        tmp = schemaLocation.Split (XmlChar.WhitespaceChars);
                                } catch (Exception ex) {
-                                       HandleError ("Invalid schemaLocation attribute format.", ex, true);
+                                       if (schemas.Count == 0)
+                                               HandleError ("Invalid schemaLocation attribute format.", ex, true);
                                        tmp = new string [0];
                                }
                                if (tmp.Length % 2 != 0)
-                                       HandleError ("Invalid schemaLocation attribute format.");
+                                       if (schemas.Count == 0)
+                                               HandleError ("Invalid schemaLocation attribute format.");
                                for (int i = 0; i < tmp.Length; i += 2) {
                                        try {
                                                schema = ReadExternalSchema (tmp [i + 1]);
                                        } catch (Exception) { // FIXME: (wishlist) It is bad manner ;-(
-                                               HandleError ("Could not resolve schema location URI: " + tmp [i + 1], null, true);
+                                               if (!schemas.Contains (tmp [i]))
+                                                       HandleError (String.Format ("Could not resolve schema location URI: {0}",
+                                                               i + 1 < tmp.Length ? tmp [i + 1] : String.Empty), null, true);
                                                continue;
                                        }
                                        if (schema.TargetNamespace == null)
@@ -1566,7 +1526,8 @@ namespace Mono.Xml.Schema
                                try {
                                        schema = ReadExternalSchema (noNsSchemaLocation);
                                } catch (Exception) { // FIXME: (wishlist) It is bad manner ;-(
-                                       HandleError ("Could not resolve schema location URI: " + noNsSchemaLocation, null, true);
+                                       if (schemas.Count != 0)
+                                               HandleError ("Could not resolve schema location URI: " + noNsSchemaLocation, null, true);
                                }
                                if (schema != null && schema.TargetNamespace != null)
                                        HandleError ("Specified schema has different target namespace.");