Author: atsushi
Date: 2007-01-05 15:14:32 -0500 (Fri, 05 Jan 2007)
New Revision: 70557

Modified:
   trunk/mcs/class/System.XML/Mono.Xml.XPath/ChangeLog
   trunk/mcs/class/System.XML/Mono.Xml.XPath/DTMXPathDocumentBuilder2.cs
   trunk/mcs/class/System.XML/Test/System.Xml.XPath/ChangeLog
   trunk/mcs/class/System.XML/Test/System.Xml.XPath/XPathNavigatorCommonTests.cs
Log:
2007-01-05  Atsushi Enomoto <[EMAIL PROTECTED]>

        * DTMXPathDocumentBuilder2.cs : fixed incorrect namespace node links
          which happened to following siblings of a node with namespaces.

        * XPathNavigatorCommonTests.cs : added test for incorrect namespace
          node links.



Modified: trunk/mcs/class/System.XML/Mono.Xml.XPath/ChangeLog
===================================================================
--- trunk/mcs/class/System.XML/Mono.Xml.XPath/ChangeLog 2007-01-05 20:06:53 UTC 
(rev 70556)
+++ trunk/mcs/class/System.XML/Mono.Xml.XPath/ChangeLog 2007-01-05 20:14:32 UTC 
(rev 70557)
@@ -1,3 +1,8 @@
+2007-01-05  Atsushi Enomoto <[EMAIL PROTECTED]>
+
+       * DTMXPathDocumentBuilder2.cs : fixed incorrect namespace node links
+         which happened to following siblings of a node with namespaces.
+
 2006-12-05  Atsushi Enomoto <[EMAIL PROTECTED]>
 
        * XPathEditableDocument.cs : those writers should lookup prefix when

Modified: trunk/mcs/class/System.XML/Mono.Xml.XPath/DTMXPathDocumentBuilder2.cs
===================================================================
--- trunk/mcs/class/System.XML/Mono.Xml.XPath/DTMXPathDocumentBuilder2.cs       
2007-01-05 20:06:53 UTC (rev 70556)
+++ trunk/mcs/class/System.XML/Mono.Xml.XPath/DTMXPathDocumentBuilder2.cs       
2007-01-05 20:14:32 UTC (rev 70557)
@@ -235,6 +235,8 @@
                                else
                                        goto default;
                        case XmlNodeType.EndElement:
+                               int endedNode = parentStack [parentStackIndex];
+                               AdjustLastNsInScope (endedNode);
                                parentStackIndex--;
                                return;
                        default:
@@ -341,8 +343,12 @@
                        hasLocalNs = false;
                        attrIndexAtStart = attributeIndex;
                        nsIndexAtStart = nsIndex;
+                       AdjustLastNsInScope (previousSibling);
+               }
 
-                       while (namespaces [lastNsInScope].DeclaredElement == 
previousSibling) {
+               private void AdjustLastNsInScope (int target)
+               {
+                       while (namespaces [lastNsInScope].DeclaredElement == 
target) {
                                lastNsInScope = namespaces 
[lastNsInScope].NextNamespace;
                        }
                }

Modified: trunk/mcs/class/System.XML/Test/System.Xml.XPath/ChangeLog
===================================================================
--- trunk/mcs/class/System.XML/Test/System.Xml.XPath/ChangeLog  2007-01-05 
20:06:53 UTC (rev 70556)
+++ trunk/mcs/class/System.XML/Test/System.Xml.XPath/ChangeLog  2007-01-05 
20:14:32 UTC (rev 70557)
@@ -1,5 +1,10 @@
 2007-01-05  Atsushi Enomoto <[EMAIL PROTECTED]>
 
+       * XPathNavigatorCommonTests.cs : added test for incorrect namespace
+         node links.
+
+2007-01-05  Atsushi Enomoto <[EMAIL PROTECTED]>
+
        * XPathNavigatorTests.cs : added test for text() and whitespace/
          significantwhitespace node.
 

Modified: 
trunk/mcs/class/System.XML/Test/System.Xml.XPath/XPathNavigatorCommonTests.cs
===================================================================
--- 
trunk/mcs/class/System.XML/Test/System.Xml.XPath/XPathNavigatorCommonTests.cs   
    2007-01-05 20:06:53 UTC (rev 70556)
+++ 
trunk/mcs/class/System.XML/Test/System.Xml.XPath/XPathNavigatorCommonTests.cs   
    2007-01-05 20:14:32 UTC (rev 70557)
@@ -41,6 +41,13 @@
                        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 ();
@@ -445,5 +452,28 @@
                        AssertEquals (ret, nav.OuterXml.Replace ("\r\n", "\n"));
                }
 #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 (""));
+               }
        }
 }

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to