You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by mr...@apache.org on 2005/11/03 07:42:03 UTC

svn commit: r330486 - in /xerces/java/trunk/src/org/apache/xerces/dom: AttributeMap.java DOMNormalizer.java

Author: mrglavas
Date: Wed Nov  2 22:41:58 2005
New Revision: 330486

URL: http://svn.apache.org/viewcvs?rev=330486&view=rev
Log:
Fixing JIRA Issue #1111:
http://issues.apache.org/jira/browse/XERCESJ-1111

When default attributes are added to the document while executing
Document.normalizeDocument() the owner element was never set and mutation
events were not being fired for the newly added nodes. Both of these bugs
should be fixed now.

Modified:
    xerces/java/trunk/src/org/apache/xerces/dom/AttributeMap.java
    xerces/java/trunk/src/org/apache/xerces/dom/DOMNormalizer.java

Modified: xerces/java/trunk/src/org/apache/xerces/dom/AttributeMap.java
URL: http://svn.apache.org/viewcvs/xerces/java/trunk/src/org/apache/xerces/dom/AttributeMap.java?rev=330486&r1=330485&r2=330486&view=diff
==============================================================================
--- xerces/java/trunk/src/org/apache/xerces/dom/AttributeMap.java (original)
+++ xerces/java/trunk/src/org/apache/xerces/dom/AttributeMap.java Wed Nov  2 22:41:58 2005
@@ -563,4 +563,37 @@
 
     } // reconcileDefaults()
 
+    protected final int addItem (Node arg) {
+        
+        final AttrImpl argn = (AttrImpl) arg;
+        
+        // set owner
+        argn.ownerNode = ownerNode;
+        argn.isOwned(true); 
+        
+        int i = findNamePoint(arg.getNamespaceURI(), arg.getLocalName());
+        if (i >= 0) {
+            nodes.setElementAt(arg,i);
+        } 
+        else {
+            // If we can't find by namespaceURI, localName, then we find by
+            // nodeName so we know where to insert.
+            i = findNamePoint(arg.getNodeName(),0);
+            if (i >= 0) {
+                nodes.insertElementAt(arg,i);
+            } 
+            else {
+                i = -1 - i; // Insert point (may be end of list)
+                if (null == nodes) {
+                    nodes = new Vector(5, 10);
+                }
+                nodes.insertElementAt(arg, i);
+            }
+        }
+        
+        // notify document
+        ownerNode.ownerDocument().setAttrNode(argn, null);
+        return i;        
+    }
+
 } // class AttributeMap

Modified: xerces/java/trunk/src/org/apache/xerces/dom/DOMNormalizer.java
URL: http://svn.apache.org/viewcvs/xerces/java/trunk/src/org/apache/xerces/dom/DOMNormalizer.java?rev=330486&r1=330485&r2=330486&view=diff
==============================================================================
--- xerces/java/trunk/src/org/apache/xerces/dom/DOMNormalizer.java (original)
+++ xerces/java/trunk/src/org/apache/xerces/dom/DOMNormalizer.java Wed Nov  2 22:41:58 2005
@@ -1461,28 +1461,28 @@
         }
 
 
-		/**
+        /**
          * This method adds default declarations
-		 * @see org.apache.xerces.xni.XMLAttributes#addAttribute(QName, String, String)
-		 */
-		public int addAttribute(QName qname, String attrType, String attrValue) {
- 			int index = fElement.getXercesAttribute(qname.uri, qname.localpart);
-			// add defaults to the tree
-			if (index < 0) {
+         * @see org.apache.xerces.xni.XMLAttributes#addAttribute(QName, String, String)
+         */
+        public int addAttribute(QName qname, String attrType, String attrValue) {
+            int index = fElement.getXercesAttribute(qname.uri, qname.localpart);
+            // add defaults to the tree
+            if (index < 0) {
                 // the default attribute was removed by a user and needed to 
                 // be added back
-				AttrImpl attr = (AttrImpl)
-					((CoreDocumentImpl) fElement.getOwnerDocument()).createAttributeNS(
-						qname.uri,
-						qname.rawname,
-						qname.localpart);
+                AttrImpl attr = (AttrImpl)
+                    ((CoreDocumentImpl) fElement.getOwnerDocument()).createAttributeNS(
+                        qname.uri,
+                        qname.rawname,
+                        qname.localpart);
                 // REVISIT: the following should also update ID table
-				index = fElement.setXercesAttributeNode(attr);
-				attr.setNodeValue(attrValue);
-				fAugmentations.insertElementAt(new AugmentationsImpl(), index);
+                attr.setNodeValue(attrValue);
+                index = fElement.setXercesAttributeNode(attr);
+                fAugmentations.insertElementAt(new AugmentationsImpl(), index);
                 attr.setSpecified(false);
-			}            
-			else {
+            }            
+            else {
                 // default attribute is in the tree
                 // we don't need to do anything since prefix was already fixed
                 // at the namespace fixup time and value must be same value, otherwise
@@ -1491,7 +1491,7 @@
                 
             }
             return index;
-		}
+        }
 
 
         public void removeAllAttributes(){



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xerces.apache.org
For additional commands, e-mail: commits-help@xerces.apache.org