2005-01-31 Zoltan Varga <vargaz@freemail.hu>
[mono.git] / mcs / class / System.XML / Mono.Xml.Schema / XsdValidatingReader.cs
index 97f4a62c363a50ac183f0760dc6ec6686b352d97..51cbbcb98c080bd289bcf1fbf7adfac7cbafd4c7 100644 (file)
@@ -215,6 +215,7 @@ namespace Mono.Xml.Schema
 
                // It is used only for independent XmlReader use, not for XmlValidatingReader.
 #if NET_2_0
+               [Obsolete]
                public override object ReadTypedValue ()
 #else
                public object ReadTypedValue ()
@@ -334,11 +335,11 @@ namespace Mono.Xml.Schema
                        get { return GetAttribute (localName, ns); }
                }
 
-               int IXmlLineInfo.LineNumber {
+               public int LineNumber {
                        get { return readerLineInfo != null ? readerLineInfo.LineNumber : 0; }
                }
 
-               int IXmlLineInfo.LinePosition {
+               public int LinePosition {
                        get { return readerLineInfo != null ? readerLineInfo.LinePosition : 0; }
                }
 
@@ -826,11 +827,10 @@ namespace Mono.Xml.Schema
                                case ContentProc.Lax:
                                        break;
                                default:
-                                       // FIXME: why is it not invalid if xsi:type exists?
                                        if (xsiTypeName == null &&
                                                (schemas.Contains (reader.NamespaceURI) ||
                                                !schemas.MissedSubComponents (reader.NamespaceURI)))
-                                               HandleError ("Element declaration for " + reader.LocalName + " is missing.");
+                                               HandleError ("Element declaration for " + new QName (reader.LocalName, reader.NamespaceURI) + " is missing.");
                                        break;
                                }
                        }
@@ -1121,7 +1121,7 @@ namespace Mono.Xml.Schema
                                XsdKeyTable seq  = (XsdKeyTable) keyTables [i];
                                if (seq.SelectorMatches (this.elementQNameStack, reader.Depth) != null) {
                                        // creates and registers new entry.
-                                       XsdKeyEntry entry = new XsdKeyEntry (seq, reader.Depth, reader as IXmlLineInfo);
+                                       XsdKeyEntry entry = new XsdKeyEntry (seq, reader.Depth, readerLineInfo);
                                        seq.Entries.Add (entry);
                                }
                        }
@@ -1146,7 +1146,7 @@ namespace Mono.Xml.Schema
                private void ProcessKeyEntry (XsdKeyEntry entry)
                {
                        bool isNil = XsiNilDepth == Depth;
-                       entry.ProcessMatch (false, elementQNameStack, this, NameTable, BaseURI, SchemaType, ParserContext.NamespaceManager, this as IXmlLineInfo, Depth, null, null, null, isNil, CurrentKeyFieldConsumers);
+                       entry.ProcessMatch (false, elementQNameStack, this, NameTable, BaseURI, SchemaType, ParserContext.NamespaceManager, readerLineInfo, Depth, null, null, null, isNil, CurrentKeyFieldConsumers);
                        if (MoveToFirstAttribute ()) {
                                try {
                                        do {
@@ -1155,7 +1155,7 @@ namespace Mono.Xml.Schema
                                                case XmlSchema.InstanceNamespace:
                                                        continue;
                                                }
-                                               entry.ProcessMatch (true, elementQNameStack, this, NameTable, BaseURI, SchemaType, ParserContext.NamespaceManager, this as IXmlLineInfo, Depth, LocalName, NamespaceURI, Value, false, CurrentKeyFieldConsumers);
+                                               entry.ProcessMatch (true, elementQNameStack, this, NameTable, BaseURI, SchemaType, ParserContext.NamespaceManager, readerLineInfo, Depth, LocalName, NamespaceURI, Value, false, CurrentKeyFieldConsumers);
                                        } while (MoveToNextAttribute ());
                                } finally {
                                        MoveToElement ();
@@ -1191,7 +1191,7 @@ namespace Mono.Xml.Schema
                                        if (identity == null)
                                                identity = value;
 
-                                       if (!field.SetIdentityField (identity, reader.Depth == xsiNilDepth, dt as XsdAnySimpleType, this.Depth, (IXmlLineInfo) this))
+                                       if (!field.SetIdentityField (identity, reader.Depth == xsiNilDepth, dt as XsdAnySimpleType, this.Depth, readerLineInfo))
                                                HandleError ("Two or more identical key value was found: '" + value + "' .");
                                        this.currentKeyFieldConsumers.RemoveAt (0);
                                }
@@ -1346,7 +1346,7 @@ namespace Mono.Xml.Schema
                        return -1;
                }
 
-               bool IXmlLineInfo.HasLineInfo ()
+               public bool HasLineInfo ()
                {
                        return readerLineInfo != null && readerLineInfo.HasLineInfo ();
                }
@@ -1508,9 +1508,10 @@ namespace Mono.Xml.Schema
                private XmlSchema ReadExternalSchema (string uri)
                {
                        Uri absUri = resolver.ResolveUri ((BaseURI != "" ? new Uri (BaseURI) : null), uri);
+                       string absUriString = absUri != null ? absUri.ToString () : String.Empty;
                        XmlTextReader xtr = null;
                        try {
-                               xtr = new XmlTextReader (absUri.ToString (),
+                               xtr = new XmlTextReader (absUriString,
                                        (Stream) resolver.GetEntity (
                                                absUri, null, typeof (Stream)),
                                        NameTable);
@@ -1723,6 +1724,21 @@ namespace Mono.Xml.Schema
                        }
                }
 
+#if NET_2_0
+               public XmlSchemaType ActualSchemaType {
+                       get {
+                               object at = ActualType;
+                               if (at == null)
+                                       return null;
+                               XmlSchemaType st = at as XmlSchemaType;
+                               if (st == null)
+                                       st = XmlSchemaType.GetBuiltInSimpleType (
+                                       ((XmlSchemaDatatype) at).TypeCode);
+                               return st;
+                       }
+               }
+#endif
+
                public bool IsInvalid {
                        get { return State == XsdValidationState.Invalid; }
                }