Author: rr
Date: Fri May  7 21:26:24 2010
New Revision: 942237

URL: http://svn.apache.org/viewvc?rev=942237&view=rev
Log:
ODE-663: Reverted for now

Modified:
    
ode/branches/APACHE_ODE_1.X/utils/src/main/java/org/apache/ode/utils/DOMUtils.java
    
ode/branches/APACHE_ODE_1.X/utils/src/test/java/org/apache/ode/utils/DOMUtilsTest.java

Modified: 
ode/branches/APACHE_ODE_1.X/utils/src/main/java/org/apache/ode/utils/DOMUtils.java
URL: 
http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/utils/src/main/java/org/apache/ode/utils/DOMUtils.java?rev=942237&r1=942236&r2=942237&view=diff
==============================================================================
--- 
ode/branches/APACHE_ODE_1.X/utils/src/main/java/org/apache/ode/utils/DOMUtils.java
 (original)
+++ 
ode/branches/APACHE_ODE_1.X/utils/src/main/java/org/apache/ode/utils/DOMUtils.java
 Fri May  7 21:26:24 2010
@@ -1155,8 +1155,16 @@ public class DOMUtils {
                        clonedNode = document.createElement(nodeName);
                        }
                }
-               
-               copyAttributes(document, sourceNode, clonedNode);
+               // attributes are not treated as child nodes, so copy them 
explicitly
+               NamedNodeMap attributes = ((Element) 
sourceNode).getAttributes();
+               for (int i = 0; i < attributes.getLength(); i++) {
+                       Attr attributeClone = (Attr) cloneNode(document, 
attributes.item(i));
+                       if (attributeClone.getNamespaceURI() == null) {
+                               ((Element) 
clonedNode).setAttributeNode(attributeClone);
+                       } else {
+                               ((Element) 
clonedNode).setAttributeNodeNS(attributeClone);
+                       }
+               }
                        break;
        case Node.ENTITY_NODE:
                // TODO
@@ -1195,25 +1203,6 @@ public class DOMUtils {
        return clonedNode;
     }
 
-    private static void copyAttributes(Document document, Node sourceNode,
-            Node clonedNode) {
-        // attributes are not treated as child nodes, so copy them explicitly
-        NamedNodeMap attributes = ((Element) sourceNode).getAttributes();
-        for (int i = 0; i < attributes.getLength(); i++) {
-            Node attrNode = attributes.item(i);
-            Document nodeDoc = attrNode.getOwnerDocument();
-            Attr attributeClone = (Attr)attrNode.cloneNode(false);
-            if (nodeDoc != null && !document.equals(nodeDoc)) {
-                attributeClone = (Attr)document.importNode(attributeClone, 
false);
-            }
-            if (attributeClone.getNamespaceURI() == null) {
-                       ((Element) clonedNode).setAttributeNode(attributeClone);
-               } else {
-                       ((Element) 
clonedNode).setAttributeNodeNS(attributeClone);
-               }
-        }
-    }
-
     /**
      * Parse the text in the cloneChild for any embedded prefixes, and define 
it in it's parent element
      *  

Modified: 
ode/branches/APACHE_ODE_1.X/utils/src/test/java/org/apache/ode/utils/DOMUtilsTest.java
URL: 
http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/utils/src/test/java/org/apache/ode/utils/DOMUtilsTest.java?rev=942237&r1=942236&r2=942237&view=diff
==============================================================================
--- 
ode/branches/APACHE_ODE_1.X/utils/src/test/java/org/apache/ode/utils/DOMUtilsTest.java
 (original)
+++ 
ode/branches/APACHE_ODE_1.X/utils/src/test/java/org/apache/ode/utils/DOMUtilsTest.java
 Fri May  7 21:26:24 2010
@@ -20,11 +20,7 @@ package org.apache.ode.utils;
 
 import org.apache.ode.utils.TestResources;
 
-import java.io.ByteArrayInputStream;
 import java.io.InputStream;
-import java.util.Map;
-
-import javax.xml.parsers.DocumentBuilderFactory;
 
 import junit.framework.TestCase;
 
@@ -114,36 +110,5 @@ public class DOMUtilsTest extends TestCa
       }
     }
   }
-  
-  public void testCloneNode() throws Exception {
-    String testString = "<ns1:parent xmlns:ns1=\"abc\">\n" +
-   "  <ns1:child xmlns=\"def\">\n" +
-   "     <ns2:nestedChild xmlns:ns2=\"def\"/>\n" +
-   "  </ns1:child>\n" +
-   "</ns1:parent>";
-    
-    Document doc = DOMUtils.parse(new 
ByteArrayInputStream(testString.getBytes()));
-    Node node = doc.getFirstChild();
-    Node clonedNode = DOMUtils.cloneNode(doc, node);
-    String actualString = DOMUtils.domToString(clonedNode).replace("<?xml 
version=\"1.0\" encoding=\"UTF-8\"?>\n", "");
-    assertEquals("XML Result", testString, actualString);
-  }
-  
-  public void testCloneNodeNewDocument() throws Exception {
-      String testString = "<ns1:parent xmlns:ns1=\"abc\">\n" +
-     "  <ns1:child xmlns=\"def\">\n" +
-     "     <ns2:nestedChild xmlns:ns2=\"def\"/>\n" +
-     "  </ns1:child>\n" +
-     "</ns1:parent>";
-      
-      Document doc = DOMUtils.parse(new 
ByteArrayInputStream(testString.getBytes()));
-      Document doc2 = 
DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
-      Node node = doc.getFirstChild();
-      Node clonedNode = DOMUtils.cloneNode(doc2, node);
-      
-      assertNotSame("DOM's are the same", doc, doc2);
-      String actualString = DOMUtils.domToString(clonedNode).replace("<?xml 
version=\"1.0\" encoding=\"UTF-8\"?>\n", "");
-      assertEquals("XML Result", testString, actualString);
-          
-  }
+
 }


Reply via email to