[Mono-bugs] [Bug 46828][Wis] New - DTM XPathNavigator does not apply xml:lang when specified on empty element

bugzilla-daemon@rocky.ximian.com bugzilla-daemon@rocky.ximian.com
Wed, 23 Jul 2003 17:34:24 -0400 (EDT)


Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by bmaurer@users.sf.net.

http://bugzilla.ximian.com/show_bug.cgi?id=46828

--- shadow/46828	Wed Jul 23 17:34:24 2003
+++ shadow/46828.tmp.26864	Wed Jul 23 17:34:24 2003
@@ -0,0 +1,122 @@
+Bug#: 46828
+Product: Mono/Class Libraries
+Version: unspecified
+OS: 
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Wishlist
+Component: System.XML
+AssignedTo: ginga@kit.hi-ho.ne.jp                            
+ReportedBy: bmaurer@users.sf.net               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: DTM XPathNavigator does not apply xml:lang when specified on empty element
+
+Description of Problem:
+The DTM XPathNavigator does not show the scope of the xml:lang attribute as
+is specified by the specifications. When given a document as such:
+
+<doc> <node xml:lang="en" /> </doc>
+
+it retuns "" when XmlLang is called when the XPathNavigator is pointed to
+/doc/node
+
+
+Steps to reproduce the problem:
+run:
+mono t.exe test.xml
+
+t.cs:
+using System;
+using System.Xml;
+using System.Xml.XPath;
+
+public class T
+{
+	
+	public static void Main (string [] args)
+	{
+		XPathNavigator d = new XPathDocument (args[0]).CreateNavigator ();
+		
+		XmlTextWriter t = new XmlTextWriter ("out-nav.xml", null);
+		
+		CopyNode (t,d);
+		t.Close ();
+		
+		XmlDocument doc = new XmlDocument ();
+		doc.Load (args[0]);
+		
+		t = new XmlTextWriter ("out-doc.xml", null);
+		CopyNode (t,doc.CreateNavigator ());
+		t.Close ();
+	}
+	
+	static void CopyNode (XmlWriter w, XPathNavigator nav)
+		{
+			switch (nav.NodeType) {
+			case XPathNodeType.Root:
+				if (nav.MoveToFirstChild ()) {
+					do {
+						CopyNode (w, nav);
+					} while (nav.MoveToNext ());
+					nav.MoveToParent ();
+				}
+				break;
+			case XPathNodeType.Element:
+				w.WriteStartElement (nav.Prefix, nav.LocalName, nav.NamespaceURI);		
+				w.WriteAttributeString ("test", "lang", "uri:test", nav.XmlLang);
+				
+				if (nav.MoveToFirstChild ()) {
+					do {
+						CopyNode (w, nav);
+					} while (nav.MoveToNext ());
+					nav.MoveToParent ();
+				}
+				
+				w.WriteEndElement ();
+				break;
+			}			
+		}
+}
+
+test.xml:
+
+<?xml version="1.0"?>
+<doc>
+	<p xml:lang="en"/>
+	<span xml:lang="en">
+		<p/>
+	</span>
+</doc>
+
+
+
+Actual Results:
+With XPathNavigator you get:
+<?xml version="1.0"?>
+<doc xmlns:test="uri:test" test:lang="">
+  <p test:lang=""/>
+  <span test:lang="en">
+    <p test:lang="en"/>
+  </span>
+</doc>
+
+Expected Results:
+In the file from XmlDocument you get:
+<?xml version="1.0"?>
+<doc xmlns:test="uri:test" test:lang="">
+  <p test:lang="en"/>
+  <span test:lang="en">
+    <p test:lang="en"/>
+  </span>
+</doc>
+
+How often does this happen? 
+Always
+
+Additional Information:
+This would affect the lang () xpath function, when it is implemented.