Nowadays, XmlDeclaratoin.WriteTo() writes PI instead of raw.
[mono.git] / mcs / class / System.XML / System.Xml / XmlValidatingReader.cs
index 3552106ea65a8f6250d564d8024620034fb787b4..de12750f0abf45f025b3286367be2114c2815e41 100644 (file)
@@ -61,7 +61,7 @@ namespace System.Xml
                bool resolverSpecified;
                ValidationType validationType;
                // for 2.0: Now it is obsolete. It is allocated only when it is required
-               XmlSchemaSet schemas;
+               XmlSchemaCollection schemas;
                DTDValidatingReader dtdReader;
                IHasXmlSchemaInfo schemaInfo;
                StringBuilder storedCharacters;
@@ -103,6 +103,12 @@ namespace System.Xml
                        get { return validatingReader == null ? sourceReader.BaseURI : validatingReader.BaseURI; }
                }
 
+#if NET_2_0
+               public override bool CanReadBinaryContent {
+                       get { return true; }
+               }
+#endif
+
                // This property for this class always return true.
                public override bool CanResolveEntity {
                        get { return true; }
@@ -283,16 +289,11 @@ namespace System.Xml
                public XmlSchemaCollection Schemas {
                        get {
                                if (schemas == null)
-                                       schemas = new XmlSchemaSet ();
-                               return schemas.SchemaCollection;
+                                       schemas = new XmlSchemaCollection (NameTable);
+                               return schemas;
                        }
                }
 
-               internal void SetSchemas (XmlSchemaSet schemas)
-               {
-                       this.schemas = schemas;
-               }
-
                public object SchemaType {
                        get { return schemaInfo.SchemaType; }
                }
@@ -304,7 +305,8 @@ namespace System.Xml
                }
 #endif
 
-               [MonoTODO ("We decided not to support XDR schema that spec is obsolete.")]
+               [MonoTODO]
+               // We decided not to support XDR schema; it is obsolete.
                public ValidationType ValidationType {
                        get { return validationType; }
                        set {
@@ -381,7 +383,12 @@ namespace System.Xml
                }
 
                XmlParserContext IHasXmlParserContext.ParserContext {
-                       get { return dtdReader != null ? dtdReader.ParserContext : null; }
+                       get {
+                               if (dtdReader != null)
+                                       return dtdReader.ParserContext;
+                               IHasXmlParserContext i = sourceReader as IHasXmlParserContext;
+                               return i != null ? i.ParserContext : null;
+                       }
                }
 
 #if NET_2_0
@@ -467,10 +474,11 @@ namespace System.Xml
                        return validatingReader.MoveToNextAttribute ();
                }
 
-               [MonoTODO ("We decided not to support XDR schema that spec is obsolete.")]
+               [MonoTODO]
+               // We decided not to support XDR schema; it is obsolete.
                public override bool Read ()
                {
-                       if (ReadState == ReadState.Initial) {
+                       if (validatingReader == null) {
                                switch (ValidationType) {
                                case ValidationType.Auto:
                                case ValidationType.None:
@@ -506,46 +514,21 @@ namespace System.Xml
                        return validatingReader.ReadAttributeValue ();
                }
 
-#if NET_1_0
-               // LAMESPEC: MS.NET 1.0 has critical bug here.
-               // After calling these methods, validation does not work anymore!
-               public override string ReadInnerXml ()
-               {
-                       if (validatingReader == null)
-                               return "";
-                       return validatingReader.ReadInnerXml ();
-               }
-
-               public override string ReadOuterXml ()
-               {
-                       if (validatingReader == null)
-                               return "";
-                       return validatingReader.ReadOuterXml ();
-               }
-#endif
-
-#if NET_1_0
-               public override string ReadString ()
-               {
-                       return base.ReadStringInternal ();
-               }
-#else
                public override string ReadString ()
                {
                        return base.ReadString ();
                }
-#endif
 
-#if NET_2_0
-               [Obsolete]
-               public override object ReadTypedValue ()
-#else
                public object ReadTypedValue ()
-#endif
                {
                        if (dtdReader == null)
                                return null;
                        XmlSchemaDatatype dt = schemaInfo.SchemaType as XmlSchemaDatatype;
+                       if (dt == null) {
+                               XmlSchemaType st = schemaInfo.SchemaType as XmlSchemaType;
+                               if (st != null)
+                                       dt = st.Datatype;
+                       }
                        if (dt == null)
                                return null;
                        switch (NodeType) {
@@ -558,6 +541,7 @@ namespace System.Xml
                                do {
                                        Read ();
                                        switch (NodeType) {
+                                       case XmlNodeType.Whitespace:
                                        case XmlNodeType.SignificantWhitespace:
                                        case XmlNodeType.Text:
                                        case XmlNodeType.CDATA:
@@ -594,7 +578,7 @@ namespace System.Xml
                }
 
 #if NET_2_0
-               [MonoTODO ("Check how expanded entity is handled here.")]
+               [MonoTODO] // FIXME: Check how expanded entity is handled here.
                public override int ReadContentAsBase64 (byte [] buffer, int offset, int length)
                {
                        if (validatingReader != null)
@@ -603,7 +587,7 @@ namespace System.Xml
                                return sourceReader.ReadContentAsBase64 (buffer, offset, length);
                }
 
-               [MonoTODO ("Check how expanded entity is handled here.")]
+               [MonoTODO] // FIXME: Check how expanded entity is handled here.
                public override int ReadContentAsBinHex (byte [] buffer, int offset, int length)
                {
                        if (validatingReader != null)
@@ -612,7 +596,7 @@ namespace System.Xml
                                return sourceReader.ReadContentAsBinHex (buffer, offset, length);
                }
 
-               [MonoTODO ("Check how expanded entity is handled here.")]
+               [MonoTODO] // FIXME: Check how expanded entity is handled here.
                public override int ReadElementContentAsBase64 (byte [] buffer, int offset, int length)
                {
                        if (validatingReader != null)
@@ -621,7 +605,7 @@ namespace System.Xml
                                return sourceReader.ReadElementContentAsBase64 (buffer, offset, length);
                }
 
-               [MonoTODO ("Check how expanded entity is handled here.")]
+               [MonoTODO] // FIXME: Check how expanded entity is handled here.
                public override int ReadElementContentAsBinHex (byte [] buffer, int offset, int length)
                {
                        if (validatingReader != null)