[Mono-bugs] [Bug 52453][Nor] New - XML attributes get out of order when using XmlAttributeCollection.InsertAfter() method.

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Mon, 22 Dec 2003 13:43:22 -0500 (EST)


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 mlasky@novell.com.

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

--- shadow/52453	2003-12-22 13:43:22.000000000 -0500
+++ shadow/52453.tmp.8442	2003-12-22 13:43:22.000000000 -0500
@@ -0,0 +1,94 @@
+Bug#: 52453
+Product: Mono/Class Libraries
+Version: unspecified
+OS: Suse 8.2
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Normal
+Component: System.XML
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: mlasky@novell.com               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: XML attributes get out of order when using XmlAttributeCollection.InsertAfter() method.
+
+Please fill in this template when reporting a bug, unless you know what you
+are doing.
+Description of Problem:
+The xml attributes on an element become unordered after calling
+XmlAttributeCollection.InsertAfter() method.  The name of the new attribute
+to insert is already present in the collection.
+
+
+Steps to reproduce the problem:
+1. Compile the following test code using 'mcs Test.cs':
+using System;
+using System.Xml;
+ 
+namespace Test
+{
+        class Test
+        {
+                static void Main()
+                {
+                        XmlDocument testDoc = new XmlDocument();
+                        XmlElement testElement = testDoc.CreateElement(
+"TestElement" );
+                        testDoc.AppendChild( testElement );
+ 
+                        XmlAttribute testAttr1 = testDoc.CreateAttribute(
+"TestAttribute1" );
+                        testAttr1.Value = "First attribute";
+                        testElement.Attributes.Prepend( testAttr1 );
+ 
+                        XmlAttribute testAttr2 = testDoc.CreateAttribute(
+"TestAttribute2" );
+                        testAttr2.Value = "Second attribute";
+                        testElement.Attributes.InsertAfter( testAttr2,
+testAttr1 );
+ 
+                        XmlAttribute testAttr3 = testDoc.CreateAttribute(
+"TestAttribute3" );
+                        testAttr3.Value = "Third attribute";
+                        testElement.Attributes.InsertAfter( testAttr3,
+testAttr2 );
+ 
+                        XmlAttribute outOfOrder = testDoc.CreateAttribute(
+"TestAttribute2" );
+                        outOfOrder.Value = "Should still be second attribute";
+                        testElement.Attributes.InsertAfter( outOfOrder,
+testElement.Attributes[ 0 ] );
+ 
+                        for ( int i = 0; i < testElement.Attributes.Count;
+++i ) 
+                        {
+                                Console.WriteLine( "Attribute {0} = {1} : {2}",
+i, testElement.Attributes[ i ].Name, testElement.Attributes[ i ].Value );
+                        }
+                }
+        }
+}
+
+2. Run 'mono Test.exe'
+3. 
+
+Actual Results:
+Attribute 0 = TestAttribute1 : First attribute
+Attribute 1 = TestAttribute3 : Third attribute
+Attribute 2 = TestAttribute2 : Should still be second attribute
+
+Expected Results:
+Attribute 0 = TestAttribute1 : First attribute
+Attribute 1 = TestAttribute2 : Should still be second attribute
+Attribute 2 = TestAttribute3 : Third attribute
+
+How often does this happen? 
+Every time.
+
+Additional Information:
+Running this with mono version 0.29.0.0.
+Running on .NET produces expected results.