You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commons-dev@ws.apache.org by ru...@apache.org on 2006/10/11 18:37:29 UTC

svn commit: r462844 - in /webservices/commons/trunk/modules/axiom/modules: axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ axiom-tests/src/test/java/org/apache/axiom/om/impl/dom/

Author: ruchithf
Date: Wed Oct 11 09:37:25 2006
New Revision: 462844

URL: http://svn.apache.org/viewvc?view=rev&rev=462844
Log:
Makesure we import if the owner document is different when a DOOM node is added and added a test

Modified:
    webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/NodeImpl.java
    webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ParentNode.java
    webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/impl/dom/ConvertLLOMToDOOMTest.java

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/NodeImpl.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/NodeImpl.java?view=diff&rev=462844&r1=462843&r2=462844
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/NodeImpl.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/NodeImpl.java Wed Oct 11 09:37:25 2006
@@ -15,25 +15,17 @@
  */
 package org.apache.axiom.om.impl.dom;
 
-import org.apache.axiom.om.OMComment;
 import org.apache.axiom.om.OMContainer;
-import org.apache.axiom.om.OMDocType;
-import org.apache.axiom.om.OMElement;
 import org.apache.axiom.om.OMException;
 import org.apache.axiom.om.OMFactory;
 import org.apache.axiom.om.OMNode;
 import org.apache.axiom.om.OMOutputFormat;
-import org.apache.axiom.om.OMProcessingInstruction;
-import org.apache.axiom.om.OMText;
 import org.apache.axiom.om.OMXMLParserWrapper;
-import org.apache.axiom.om.util.StAXUtils;
-import org.apache.axiom.om.impl.OMNodeEx;
 import org.apache.axiom.om.impl.MTOMXMLStreamWriter;
-import org.apache.axiom.om.impl.builder.StAXOMBuilder;
-import org.apache.axiom.om.impl.dom.factory.OMDOMFactory;
+import org.apache.axiom.om.impl.OMNodeEx;
+import org.apache.axiom.om.util.StAXUtils;
 import org.w3c.dom.DOMException;
 import org.w3c.dom.Document;
-import org.w3c.dom.Element;
 import org.w3c.dom.NamedNodeMap;
 import org.w3c.dom.Node;
 import org.w3c.dom.NodeList;
@@ -41,6 +33,7 @@
 
 import javax.xml.stream.XMLStreamException;
 import javax.xml.stream.XMLStreamWriter;
+
 import java.io.OutputStream;
 import java.io.Writer;
 import java.util.Hashtable;

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ParentNode.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ParentNode.java?view=diff&rev=462844&r1=462843&r2=462844
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ParentNode.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ParentNode.java Wed Oct 11 09:37:25 2006
@@ -27,8 +27,6 @@
 import org.apache.axiom.om.impl.OMNodeEx;
 import org.apache.axiom.om.impl.builder.StAXOMBuilder;
 import org.apache.axiom.om.impl.dom.factory.OMDOMFactory;
-import org.apache.axiom.om.impl.llom.OMNodeImpl;
-import org.apache.axiom.om.impl.llom.factory.OMLinkedListImplFactory;
 import org.apache.axiom.om.impl.traverse.OMChildrenIterator;
 import org.apache.axiom.om.impl.traverse.OMChildrenQNameIterator;
 import org.w3c.dom.DOMException;
@@ -38,6 +36,7 @@
 import org.w3c.dom.NodeList;
 
 import javax.xml.namespace.QName;
+
 import java.util.Iterator;
 
 public abstract class ParentNode extends ChildNode implements OMContainerEx {
@@ -63,7 +62,12 @@
 
     public void addChild(OMNode omNode) {
 		if (omNode.getOMFactory() instanceof OMDOMFactory) {
-			this.appendChild((Node) omNode);
+            Node domNode= (Node)omNode;
+            if(this.ownerNode != null && !domNode.getOwnerDocument().equals(this.ownerNode)) {
+                this.appendChild(this.ownerNode.importNode(domNode, true));
+            } else {
+                this.appendChild(domNode);
+            }
 		} else {
 			addChild(importNode(omNode));
 		}

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/impl/dom/ConvertLLOMToDOOMTest.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/impl/dom/ConvertLLOMToDOOMTest.java?view=diff&rev=462844&r1=462843&r2=462844
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/impl/dom/ConvertLLOMToDOOMTest.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/impl/dom/ConvertLLOMToDOOMTest.java Wed Oct 11 09:37:25 2006
@@ -141,4 +141,27 @@
             fail(e.getMessage());
         }
     }
+    
+    public void testAddChild() {
+        try {
+            SOAPFactory fac = DOOMAbstractFactory.getSOAP11Factory();
+            SOAPEnvelope env = fac.getDefaultEnvelope();
+            fac.createOMElement(new QName("http://test.org", "Test"), env.getBody());
+            env.build();
+            
+            SOAPFactory llomFac = DOOMAbstractFactory.getSOAP11Factory();
+            OMElement elem = llomFac.createOMElement("newDomElement", null);
+            
+            OMElement firstElement = env.getBody().getFirstElement();
+            firstElement.addChild(elem);
+            
+            assertTrue("New DOM child missing", 
+                    env.toString().indexOf("newDomElement") > 0);
+            
+        } catch (Exception e) {
+            e.printStackTrace();
+            fail(e.getMessage());
+        }
+    }
+    
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: commons-dev-help@ws.apache.org