* XmlTextReaderTests.cs: Added ParsingWithNSMgrSubclass test to check
authorAndreia Gaita <avidigal@novell.com>
Fri, 13 Nov 2009 21:26:27 +0000 (21:26 -0000)
committerAndreia Gaita <avidigal@novell.com>
Fri, 13 Nov 2009 21:26:27 +0000 (21:26 -0000)
r146175 fix (chained namespace lookups using XmlNamespaceManager
subclasses)

svn path=/trunk/mcs/; revision=146179

mcs/class/System.XML/Test/System.Xml/ChangeLog
mcs/class/System.XML/Test/System.Xml/XmlTextReaderTests.cs

index 00e3f1358048276d221bb63bccecf248895673e3..0ea8c18abfe68e7cb989b03302bd3090fa18b36c 100644 (file)
@@ -1,3 +1,9 @@
+2009-11-13  Andreia Gaita  <avidigal@novell.com>
+
+       * XmlTextReaderTests.cs: Added ParsingWithNSMgrSubclass test to check
+       r146175 fix (chained namespace lookups using XmlNamespaceManager
+       subclasses)
+
 2009-11-11  Atsushi Enomoto  <atsushi@ximian.com>
 
        * XmlNodeReaderTests.cs : added test for bug #550379.
index fc868fb373b8954ec1a5aa120a64ddaad4a28f0d..21c49abfff685a2056986ff8625a07117168cbd7 100644 (file)
@@ -1304,5 +1304,42 @@ namespace MonoTests.System.Xml
                        while (!xtr.EOF)
                                xtr.Read ();
                }
+
+               [Test]
+               public void ParsingWithNSMgrSubclass ()
+               {
+                       XmlNamespaceManager nsMgr = new XmlNamespaceManager (new NameTable ());
+                       nsMgr.AddNamespace ("foo", "bar");
+                       XmlParserContext inputContext = new XmlParserContext (null, nsMgr, null, XmlSpace.None);
+                       XmlReader xr = XmlReader.Create (new StringReader ("<empty/>"), new XmlReaderSettings (), inputContext);
+
+                       XmlNamespaceManager aMgr = new MyNS (xr);
+                       XmlParserContext inputContext2 = new XmlParserContext(null, aMgr, null, XmlSpace.None);
+                       XmlReader xr2 = XmlReader.Create (new StringReader ("<foo:haha>namespace test</foo:haha>"), new XmlReaderSettings (), inputContext2);
+
+                       while (xr2.Read ()) {}
+
+               }
+
+
+               // The MyNS subclass chains namespace lookups
+               class MyNS : XmlNamespaceManager {
+                       private XmlReader xr;
+
+
+                       public MyNS (XmlReader xr)
+                               : base (xr.NameTable) {
+                               this.xr = xr;
+                       }
+
+                       public override string LookupNamespace (string prefix) {
+                               string str = base.LookupNamespace (prefix);
+                               if (!string.IsNullOrEmpty (str))
+                                       return str;
+                               if (xr != null)
+                                       return xr.LookupNamespace (prefix);
+                               return String.Empty;
+                       }
+               }
        }
 }