return xpathDocument.CreateNavigator ();
}
+ private XPathNavigator GetXPathDocumentNavigator (XmlNode node, XmlSpace space)
+ {
+ XmlNodeReader xr = new XmlNodeReader (node);
+ xpathDocument = new XPathDocument (xr, space);
+ return xpathDocument.CreateNavigator ();
+ }
+
private void AssertNavigator (string label, XPathNavigator nav, XPathNodeType type, string prefix, string localName, string ns, string name, string value, bool hasAttributes, bool hasChildren, bool isEmptyElement)
{
label += nav.GetType ();
</one>";
AssertEquals (ret, nav.OuterXml.Replace ("\r\n", "\n"));
}
+
+ [Test]
+ public void ReadSubtreeLookupNamespace ()
+ {
+ string xml = "<x:foo xmlns:x='urn:x'><bar>x:val</bar></x:foo>";
+ var doc = new XmlDocument ();
+ doc.LoadXml (xml);
+ XPathNavigator nav = doc.LastChild.LastChild.CreateNavigator ();
+ var xr = nav.ReadSubtree ();
+ xr.MoveToContent ();
+ xr.Read (); // should be at x:val
+ AssertEquals ("urn:x", xr.LookupNamespace ("x"));
+ }
#endif
+
+ [Test]
+ public void GetNamespaceConsistentTree ()
+ {
+ document.PreserveWhitespace = true;
+
+ string xml = "<x:root xmlns:x='urn:x'> <x:foo xmlns='ns1'> <x:bar /> </x:foo> <x:foo xmlns:y='ns2'> <x:bar /> </x:foo></x:root>";
+ nav = GetXmlDocumentNavigator (xml);
+ GetNamespaceConsistentTree (nav);
+ nav = GetXPathDocumentNavigator (document, XmlSpace.Preserve);
+ GetNamespaceConsistentTree (nav);
+ }
+
+ private void GetNamespaceConsistentTree (XPathNavigator nav)
+ {
+ nav.MoveToFirstChild ();
+ nav.MoveToFirstChild ();
+ nav.MoveToNext ();
+ AssertEquals ("#1." + nav.GetType (), "ns1", nav.GetNamespace (""));
+ nav.MoveToNext ();
+ nav.MoveToNext ();
+ AssertEquals ("#2." + nav.GetType (), "", nav.GetNamespace (""));
+ }
}
-}
+}
\ No newline at end of file