2009-09-15 Atsushi Enomoto <atsushi@ximian.com>
authorAtsushi Eno <atsushieno@gmail.com>
Tue, 15 Sep 2009 12:40:28 +0000 (12:40 -0000)
committerAtsushi Eno <atsushieno@gmail.com>
Tue, 15 Sep 2009 12:40:28 +0000 (12:40 -0000)
* XmlAttributeCollection.cs : removed duplicate ID attribute check
  here as this behavior not specifically defined by W3C DOM Level 2
  specification. Fixed bug #508296.

* XmlAttributeCollectionTests.cs : add test for bug #508296 by
  Tom Hindle.

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

mcs/class/System.XML/System.Xml/ChangeLog
mcs/class/System.XML/System.Xml/XmlAttributeCollection.cs
mcs/class/System.XML/Test/System.Xml/ChangeLog
mcs/class/System.XML/Test/System.Xml/XmlAttributeCollectionTests.cs

index 429186c5d9113bd79f6a73024f2a27c6370507d4..329fc7c08aa97b3c5c22041706ca7e1c1475fc9f 100644 (file)
@@ -1,3 +1,9 @@
+2009-09-15  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * XmlAttributeCollection.cs : removed duplicate ID attribute check
+         here as this behavior not specifically defined by W3C DOM Level 2
+         specification. Fixed bug #508296.
+
 2009-08-21  Atsushi Enomoto  <atsushi@ximian.com>
 
        * XmlTextReader.cs : there still was use of bogus
index 138d9ece9b403d970ab416eae60dee74b1855795..e450d2d540b0539482516eff5c45ab5ee2965774 100644 (file)
@@ -334,14 +334,6 @@ namespace System.Xml
                        if (attdef == null || attdef.Datatype.TokenizedType != XmlTokenizedType.ID)
                                return;
 
-                       // adding new identical attribute, but 
-                       // MS.NET is pity for ID support, so I'm wondering how to correct it...
-                       if (ownerElement.IsRooted) {
-                               XmlAttribute dup = ownerDocument.GetIdenticalAttribute (node.Value);
-                               if (dup != null && dup.OwnerElement != null && dup.OwnerElement.IsRooted)
-                                       throw new XmlException (String.Format (
-                                               "ID value {0} already exists in this document.", node.Value));
-                       }
                        ownerDocument.AddIdenticalAttribute (node);
                }
 
index eedef530870ac9e8e10918bd56e748a1561f41ef..80df74ed61c90f0a684c13deff3e0633e61ab10e 100644 (file)
@@ -1,3 +1,8 @@
+2009-09-15  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * XmlAttributeCollectionTests.cs : add test for bug #508296 by
+         Tom Hindle.
+
 2009-08-21  Atsushi Enomoto  <atsushi@ximian.com>
 
        * XmlTextReaderTests.cs : added test for null nametable in parser
index 4193f805396d521964750c8e3f530ef7511febb4..09983f1bf0ef22d979f0582dcfaa9861e704e5e8 100644 (file)
@@ -223,5 +223,23 @@ namespace MonoTests.System.Xml
                        doc.SelectNodes ("//mynode") [0].Attributes.Append (a);
                        doc.SelectNodes ("//mynode") [0].Attributes.Append (a);
                }
+
+               [Test]
+               public void AddIdentityDuplicate ()
+               {
+                       XmlDocument doc = new XmlDocument ();
+                       doc.LoadXml (@"
+                               <!DOCTYPE eticGlossList [<!ELEMENT item (item*)><!ATTLIST item id ID #IMPLIED>]>
+                               <group><item></item><item id=""tom""><f/></item></group>");
+                       XmlNodeList nodes = doc.SelectNodes ("group/item");
+                       int n = 1;
+                       foreach (XmlNode node in nodes) {
+                               XmlAttribute idAttr = doc.CreateAttribute ("id");
+
+                               idAttr.Value = "id";
+                               node.Attributes.Append (idAttr);
+                               Assert.AreEqual (1, node.Attributes.Count, "#" + n++);
+                       }
+               }
        }
 }