axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ruchi...@apache.org
Subject svn commit: r358243 - in /webservices/axis2/trunk/java/modules: saaj/src/org/apache/axis2/om/impl/dom/ saaj/src/org/apache/axis2/om/impl/dom/factory/ xml/src/org/apache/axis2/om/impl/llom/ xml/src/org/apache/axis2/soap/impl/llom/
Date Wed, 21 Dec 2005 09:35:18 GMT
Author: ruchithf
Date: Wed Dec 21 01:34:34 2005
New Revision: 358243

URL: http://svn.apache.org/viewcvs?rev=358243&view=rev
Log:
- DOOM: Now we can add comments to XML documents
- Renamed 'rootElement' in OMDocumentImpl to 'documentElement'


Modified:
    webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/om/impl/dom/DocumentImpl.java
    webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/om/impl/dom/ParentNode.java
    webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/om/impl/dom/factory/OMDOMFactory.java
    webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/llom/OMDocumentImpl.java
    webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/soap/impl/llom/SOAPMessageImpl.java

Modified: webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/om/impl/dom/DocumentImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/om/impl/dom/DocumentImpl.java?rev=358243&r1=358242&r2=358243&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/om/impl/dom/DocumentImpl.java
(original)
+++ webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/om/impl/dom/DocumentImpl.java
Wed Dec 21 01:34:34 2005
@@ -56,6 +56,8 @@
     
     private String charEncoding;
     
+    protected ElementImpl documentElement;
+    
 	/**
 	 * @param ownerDocument
 	 */
@@ -380,10 +382,10 @@
 		 * We'r sure that only an element can be the first child 
 		 * of a Document
 		 */
-		if(this.firstChild == null && !this.done) {
+		if(this.documentElement == null && !this.done) {
 			this.build();
 		}
-		return (OMElement)this.firstChild;
+		return this.documentElement;
 	}
 	
 	/**
@@ -392,11 +394,7 @@
 	 */
 	public Element getDocumentElement() {
 		
-		if(this.firstChild == null && !this.done) {
-			this.build();
-		}
-			
-		return (Element)this.firstChild;
+		return (Element)this.getOMDocumentElement();
 	}
 	
     /**

Modified: webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/om/impl/dom/ParentNode.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/om/impl/dom/ParentNode.java?rev=358243&r1=358242&r2=358243&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/om/impl/dom/ParentNode.java
(original)
+++ webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/om/impl/dom/ParentNode.java
Wed Dec 21 01:34:34 2005
@@ -15,6 +15,10 @@
  */
 package org.apache.axis2.om.impl.dom;
 
+import java.util.Iterator;
+
+import javax.xml.namespace.QName;
+
 import org.apache.axis2.om.OMElement;
 import org.apache.axis2.om.OMException;
 import org.apache.axis2.om.OMNode;
@@ -27,10 +31,6 @@
 import org.w3c.dom.Node;
 import org.w3c.dom.NodeList;
 
-import java.util.Iterator;
-
-import javax.xml.namespace.QName;
-
 public abstract class ParentNode extends ChildNode implements OMContainerEx {
 
 
@@ -165,20 +165,18 @@
 		}
 		
 		if(this instanceof Document) {
-			if(this.firstChild != null) {
+			if(((DocumentImpl)this).documentElement != null && !(newDomChild instanceof CommentImpl))
{
 				//Throw exception since there cannot be two document elements
 				throw new DOMException(DOMException.HIERARCHY_REQUEST_ERR,
 						DOMMessageFormatter.formatMessage(
 								DOMMessageFormatter.DOM_DOMAIN,
 								"HIERARCHY_REQUEST_ERR", null));
-			} else {
-				this.firstChild = newDomChild;
-				newDomChild.isFirstChild(true);
-				this.lastChild = newDomChild;
+			} else if(newDomChild instanceof ElementImpl) {
 				if(newDomChild.parentNode == null) {
 					newDomChild.parentNode = this;
 				}
-				return newDomChild;
+				//set the document element
+				((DocumentImpl)this).documentElement = (ElementImpl)newDomChild;
 			}
 		}
 		
@@ -309,9 +307,6 @@
 					ChildNode child = (ChildNode)docFrag.getFirstChild();
 					child.parentNode = this;
 					this.replaceChild(child, oldChild);
-//					DocumentFragmentimpl docFrag = (DocumentFragmentimpl)newDomChild;
-//					docFrag.firstChild.previousSubling = oldDomChild.previousSubling;
-//					
 				} else {
 					if(oldDomChild.isFirstChild()) {
 						oldDomChild.detach();

Modified: webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/om/impl/dom/factory/OMDOMFactory.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/om/impl/dom/factory/OMDOMFactory.java?rev=358243&r1=358242&r2=358243&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/om/impl/dom/factory/OMDOMFactory.java
(original)
+++ webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/om/impl/dom/factory/OMDOMFactory.java
Wed Dec 21 01:34:34 2005
@@ -237,7 +237,14 @@
 	}
 
 	public OMComment createOMComment(OMContainer parent, String content) {
-		CommentImpl comment = new CommentImpl((DocumentImpl)((ElementImpl)parent).getOwnerDocument(),
content);
+		DocumentImpl doc = null;
+		if(parent instanceof DocumentImpl) {
+			doc = (DocumentImpl)parent;
+		} else {
+			doc = (DocumentImpl)((ParentNode)parent).getOwnerDocument();
+		}
+		
+		CommentImpl comment = new CommentImpl(doc, content);
 		parent.addChild(comment);
 		return comment;
 	}

Modified: webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/llom/OMDocumentImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/llom/OMDocumentImpl.java?rev=358243&r1=358242&r2=358243&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/llom/OMDocumentImpl.java
(original)
+++ webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/llom/OMDocumentImpl.java
Wed Dec 21 01:34:34 2005
@@ -16,32 +16,32 @@
 
 package org.apache.axis2.om.impl.llom;
 
+import java.io.OutputStream;
+import java.util.Iterator;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+
 import org.apache.axis2.om.OMDocument;
 import org.apache.axis2.om.OMElement;
 import org.apache.axis2.om.OMException;
 import org.apache.axis2.om.OMNode;
-import org.apache.axis2.om.OMXMLParserWrapper;
 import org.apache.axis2.om.OMOutputFormat;
+import org.apache.axis2.om.OMXMLParserWrapper;
 import org.apache.axis2.om.impl.OMContainerEx;
 import org.apache.axis2.om.impl.OMNodeEx;
 import org.apache.axis2.om.impl.OMOutputImpl;
 import org.apache.axis2.om.impl.llom.traverse.OMChildrenIterator;
 import org.apache.axis2.om.impl.llom.traverse.OMChildrenQNameIterator;
 
-import javax.xml.namespace.QName;
-import javax.xml.stream.XMLStreamException;
-import java.util.Iterator;
-import java.io.OutputStream;
-import java.io.IOException;
-
 /**
  * Class OMDocumentImpl
  */
 public class OMDocumentImpl implements OMDocument, OMContainerEx {
     /**
-     * Field rootElement
+     * Field documentElement
      */
-    protected OMElement rootElement;
+    protected OMElement documentElement;
 
     /**
      * Field firstChild
@@ -85,11 +85,11 @@
     }
 
     /**
-     * @param rootElement
+     * @param documentElement
      * @param parserWrapper
      */
-    public OMDocumentImpl(OMElement rootElement, OMXMLParserWrapper parserWrapper) {
-        this.rootElement = rootElement;
+    public OMDocumentImpl(OMElement documentElement, OMXMLParserWrapper parserWrapper) {
+        this.documentElement = documentElement;
         this.parserWrapper = parserWrapper;
     }
 
@@ -101,24 +101,24 @@
     }
 
     /**
-     * Method getRootElement
+     * Method getDocumentElement
      *
      * @return om element
      */
     public OMElement getOMDocumentElement() {
-        while (rootElement == null) {
+        while (documentElement == null) {
             parserWrapper.next();
         }
-        return rootElement;
+        return documentElement;
     }
 
     /**
-     * Method setRootElement
+     * Method setDocumentElement
      *
-     * @param rootElement
+     * @param documentElement
      */
-    public void setOMDocumentElement(OMElement rootElement) {
-        this.rootElement = rootElement;
+    public void setOMDocumentElement(OMElement documentElement) {
+        this.documentElement = documentElement;
     }
 
     /**
@@ -157,9 +157,9 @@
      */
     public void addChild(OMNode child) {
     	if(child instanceof OMElement) {
-    		if(this.rootElement == null) {
+    		if(this.documentElement == null) {
     			addChild((OMNodeImpl) child);
-    			this.rootElement = (OMElement)child;
+    			this.documentElement = (OMElement)child;
     		} else {
     			throw new OMException("Document element already exists");
     		}

Modified: webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/soap/impl/llom/SOAPMessageImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/soap/impl/llom/SOAPMessageImpl.java?rev=358243&r1=358242&r2=358243&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/soap/impl/llom/SOAPMessageImpl.java
(original)
+++ webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/soap/impl/llom/SOAPMessageImpl.java
Wed Dec 21 01:34:34 2005
@@ -49,7 +49,7 @@
 
     public void setSOAPEnvelope(SOAPEnvelope envelope) throws SOAPProcessingException {
         super.addChild(envelope);
-        this.rootElement = envelope;
+        this.documentElement = envelope;
     }
 
     public void setOMDocumentElement(OMElement rootElement) {
@@ -62,9 +62,9 @@
 
     protected void serialize(OMOutputImpl omOutput, boolean cache, boolean includeXMLDeclaration)
throws XMLStreamException {
         if (cache) {
-            ((OMNodeEx)this.rootElement).serialize(omOutput);
+            ((OMNodeEx)this.documentElement).serialize(omOutput);
         } else {
-            ((OMNodeEx)this.rootElement).serializeAndConsume(omOutput);
+            ((OMNodeEx)this.documentElement).serializeAndConsume(omOutput);
         }
     }
 }



Mime
View raw message