[Xml] Fix GetAttribute to handle null namespaces properly, add unit test.
[mono.git] / mcs / class / System.XML / System.Xml / XmlTextReader2.cs
index 803898249eec0b706e9a526137f1531e895c0ff9..b975f9849e384777d14b81a7282312e9ae175fea 100644 (file)
@@ -40,6 +40,19 @@ using Mono.Xml;
 
 namespace System.Xml
 {
+       // FIXME: this implementation requires somewhat significant change
+       // to expand entities and merge sequential text and entity references
+       // especially to handle whitespace-only entities (such as bug #372839).
+       //
+       // To do it, we have to read ahead the next node when the input is
+       // text, whitespace or significant whitespace and check if the next
+       // node is EntityReference. If it is entref, then it have to merge
+       // the input entity if it is a text.
+       //
+       // This "read ahead" operation may result in proceeding to the next
+       // element, which badly affects IXmlNamespaceResolverimplementation.
+       // So we cannot fix this in simple way.
+
        [PermissionSet (SecurityAction.InheritanceDemand, Unrestricted = true)]
        public class XmlTextReader : XmlReader,
                IXmlLineInfo, IXmlNamespaceResolver, IHasXmlParserContext
@@ -129,9 +142,9 @@ namespace System.Xml
                        source = new XmlTextReaderImpl (baseURI, xmlFragment, fragType, context);
                }
 
-               internal XmlTextReader (bool dummy, string url, XmlNodeType fragType, XmlParserContext context)
+               internal XmlTextReader (bool dummy, XmlResolver resolver, string url, XmlNodeType fragType, XmlParserContext context)
                {
-                       source = new XmlTextReaderImpl (dummy, url, fragType, context);
+                       source = new XmlTextReaderImpl (dummy, resolver, url, fragType, context);
                }
 
                private XmlTextReader (XmlTextReaderImpl entityContainer, bool insideAttribute)
@@ -580,11 +593,12 @@ namespace System.Xml
                public void ResetState ()
                {
                        if (entity != null)
-                               entity.ResetState ();
+                               CloseEntity ();
                        source.ResetState ();
                }
 
-               public override void ResolveEntity ()
+               public override
+               void ResolveEntity ()
                {
                        if (entity != null)
                                entity.ResolveEntity ();
@@ -620,7 +634,7 @@ namespace System.Xml
                        base.Skip ();
                }
 
-               [MonoTODO ("Check how expanded entity is handled here.")]
+               [MonoTODO] // FIXME: Check how expanded entity is handled here.
                public TextReader GetRemainder ()
                {
                        if (entity != null) {
@@ -636,7 +650,7 @@ namespace System.Xml
                        return true;
                }
 
-               [MonoTODO ("Check how expanded entity is handled here.")]
+               [MonoTODO] // FIXME: Check how expanded entity is handled here.
                public int ReadBase64 (byte [] buffer, int offset, int length)
                {
                        if (entity != null)
@@ -645,7 +659,7 @@ namespace System.Xml
                                return source.ReadBase64 (buffer, offset, length);
                }
 
-               [MonoTODO ("Check how expanded entity is handled here.")]
+               [MonoTODO] // FIXME: Check how expanded entity is handled here.
                public int ReadBinHex (byte [] buffer, int offset, int length)
                {
                        if (entity != null)
@@ -654,7 +668,7 @@ namespace System.Xml
                                return source.ReadBinHex (buffer, offset, length);
                }
 
-               [MonoTODO ("Check how expanded entity is handled here.")]
+               [MonoTODO] // FIXME: Check how expanded entity is handled here.
                public int ReadChars (char [] buffer, int offset, int length)
                {
                        if (entity != null)
@@ -664,7 +678,7 @@ namespace System.Xml
                }
 
 
-               [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 (entity != null)
@@ -673,7 +687,7 @@ namespace System.Xml
                                return source.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 (entity != null)
@@ -682,7 +696,7 @@ namespace System.Xml
                                return source.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 (entity != null)
@@ -691,7 +705,7 @@ namespace System.Xml
                                return source.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 (entity != null)