You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by di...@apache.org on 2006/01/03 01:29:01 UTC

svn commit: r365487 [2/5] - in /webservices/axis2/trunk/java/modules/saaj: ./ src/org/apache/axis2/saaj/ src/org/apache/axis2/util/ test/org/apache/axis2/saaj/

Modified: webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/SOAPElementImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/SOAPElementImpl.java?rev=365487&r1=365486&r2=365487&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/SOAPElementImpl.java (original)
+++ webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/SOAPElementImpl.java Mon Jan  2 16:28:43 2006
@@ -15,846 +15,579 @@
  */
 package org.apache.axis2.saaj;
 
+import org.apache.axis2.om.OMAttribute;
+import org.apache.axis2.om.OMContainer;
+import org.apache.axis2.om.OMException;
 import org.apache.axis2.om.OMNamespace;
-import org.apache.axis2.om.impl.OMNodeEx;
+import org.apache.axis2.om.OMNode;
+import org.apache.axis2.om.impl.OMOutputImpl;
+import org.apache.axis2.om.impl.dom.DocumentImpl;
+import org.apache.axis2.om.impl.dom.ElementImpl;
+import org.apache.axis2.om.impl.dom.TextImpl;
 import org.w3c.dom.Attr;
 import org.w3c.dom.DOMException;
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
 import org.w3c.dom.NodeList;
-import org.w3c.dom.TypeInfo;
+import org.w3c.dom.Text;
 
 import javax.xml.namespace.QName;
 import javax.xml.soap.Name;
 import javax.xml.soap.SOAPElement;
 import javax.xml.soap.SOAPException;
+import javax.xml.stream.XMLStreamException;
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.Iterator;
 
-/**
- * Class SOAPElementImpl
- */
-public class SOAPElementImpl extends NodeImpl implements SOAPElement {
-    /**
-     * Field omElement
-     * The corresponding OM object for SOAPElement is OMElement, so we would
-     * have a datamember of type OMElement in this class
-     */
-    protected org.apache.axis2.om.OMElement omElement;
 
-    /**
-     * Constructor SOAPElementImpl
-     * The standard constructor for being able to create SOAPElement given a omElement
-     *
-     * @param omElement
-     */
-    public SOAPElementImpl(org.apache.axis2.om.OMElement omElement) {
-        super(omElement);
-        this.omElement = omElement;
-    }
+public class SOAPElementImpl extends NodeImplEx implements SOAPElement {
 
-    /**
-     * Constructor SOAPElementImpl
-     * The empty constructor
-     */
-    public SOAPElementImpl() {
-        super();
-    }
 
     /**
-     * Method getOMElement
-     * getter method on the data member omElement
-     *
-     * @return
+     * Using a delegate because we can't extend from
+     * org.apache.axis2.om.impl.dom.ElementImpl since this class
+     * must extend SNodeImpl
      */
-    public org.apache.axis2.om.OMElement getOMElement() {
-        return this.omElement;
-    }
+    protected ElementImpl element;
 
-    /**
-     * Method addChildElement
-     *
-     * @param name
-     * @return SOAPElement
-     * @throws SOAPException
-     * @see javax.xml.soap.SOAPElement#addChildElement(javax.xml.soap.Name)
-     */
-    public SOAPElement addChildElement(Name name) throws SOAPException {
-        //We will create a new OMElement and add that as a child to the OMElement datamember that
-        //we are carrying along. And return back a wrapped SOAPElement corresponding to the
-        //created OMElement
-
-        //Since a <code>Name</code> object is given as parameter we should try to create an OMElement
-        //and register it with the contents of the <code>name</code> element
-        org.apache.axis2.om.OMElement newOMElement = org.apache.axis2.om.OMAbstractFactory.getOMFactory()
-                .createOMElement(
-                        new QName(name.getURI(),
-                                name.getLocalName(),
-                                name.getPrefix()),
-                        omElement);
-        omElement.addChild(newOMElement);
-        return new SOAPElementImpl(newOMElement);
+    public SOAPElementImpl(ElementImpl element) {
+        this.element = element;
     }
 
-    /**
-     * Method addChildElement
-     *
-     * @param localName
-     * @return
-     * @throws SOAPException
-     * @see javax.xml.soap.SOAPElement#addChildElement(java.lang.String)
-     */
-    public SOAPElement addChildElement(String localName) throws SOAPException {
-        //We will create a new OMElement and add that as a child to the OMElement datamember that
-        //we are carrying along. And return back a wrapped SOAPElement corresponding to the
-        //created OMElement
-        org.apache.axis2.om.OMElement newOMElement = org.apache.axis2.om.OMAbstractFactory.getOMFactory()
-                .createOMElement(new QName(localName), omElement);
-        omElement.addChild(newOMElement);
-        return new SOAPElementImpl(newOMElement);
-    }
-
-    /**
-     * Method addChildElement
-     *
-     * @param localName
-     * @param prefix
-     * @return
-     * @throws SOAPException
-     * @see javax.xml.soap.SOAPElement#addChildElement(java.lang.String, java.lang.String)
-     */
-    public SOAPElement addChildElement(String localName, String prefix)
-            throws SOAPException {
-        org.apache.axis2.om.OMElement newOMElement = org.apache.axis2.om.OMAbstractFactory.getOMFactory()
-                .createOMElement(new QName(null, localName, prefix),
-                        omElement);
-        omElement.addChild(newOMElement);
-        return new SOAPElementImpl(newOMElement);
+    /* (non-Javadoc)
+      * @see org.apache.axis2.om.OMNode#discard()
+      */
+    public void discard() throws OMException {
+        this.element.discard();
     }
 
-    /**
-     * Method addChildElement
-     *
-     * @param localName
-     * @param prefix
-     * @return
-     * @throws SOAPException
-     * @see javax.xml.soap.SOAPElement#addChildElement(java.lang.String, java.lang.String, java.lang.String)
-     */
-    public SOAPElement addChildElement(String localName, String prefix,
-                                       String uri) throws SOAPException {
-        org.apache.axis2.om.OMElement newOMElement = org.apache.axis2.om.OMAbstractFactory.getOMFactory()
-                .createOMElement(new QName(uri, localName, prefix), omElement);
-        omElement.addChild(newOMElement);
-        return new SOAPElementImpl(newOMElement);
+    /* (non-Javadoc)
+      * @see org.apache.axis2.om.OMNode#serialize(org.apache.axis2.om.impl.OMOutputImpl)
+      */
+    public void serialize(OMOutputImpl omOutput) throws XMLStreamException {
+        this.element.serialize(omOutput);
     }
 
-    /**
-     * Method addChildElement
-     *
-     * @param element
-     * @return
-     * @throws SOAPException
-     * @see javax.xml.soap.SOAPElement#addChildElement(javax.xml.soap.SOAPElement)
-     */
-    public SOAPElement addChildElement(SOAPElement element)
-            throws SOAPException {
-        //TODO:
-        //The fragment rooted in element is either added as a whole or not at all, if there was an error.
-        //The fragment rooted in element cannot contain elements named ?Envelope?, ?Header? or ?Body?
-        //and in the SOAP namespace. Any namespace prefixes present in the fragment should be fully
-        //resolved using appropriate namespace declarations within the fragment itself.
-
-        org.apache.axis2.om.OMElement omElementToAdd = ((SOAPElementImpl) element).getOMElement();
-        ((OMNodeEx)omElementToAdd).setParent(omElement);
-        omElement.addChild(omElementToAdd);
-        return new SOAPElementImpl(omElementToAdd);
+    /* (non-Javadoc)
+      * @see org.apache.axis2.om.OMNode#serializeAndConsume(org.apache.axis2.om.impl.OMOutputImpl)
+      */
+    public void serializeAndConsume(OMOutputImpl omOutput) throws XMLStreamException {
+        this.element.serializeAndConsume(omOutput);
     }
 
     /**
-     * Method addTextNode
-     *
-     * @param text
-     * @return
-     * @throws SOAPException
-     * @see javax.xml.soap.SOAPElement#addTextNode(java.lang.String)
-     */
-    public SOAPElement addTextNode(String text) throws SOAPException {
-        //We need to create an OMText node and add that to
-        //the omElement delegate member that we have with us. All this OMElement's setText() does
-        omElement.setText(text);
+     * Adds an attribute with the specified name and value to this
+     * <code>SOAPElement</code> object.
+     * <p/>
+     *
+     * @param name  a <code>Name</code> object with the name of the attribute
+     * @param value a <code>String</code> giving the value of the attribute
+     * @return the <code>SOAPElement</code> object into which the attribute was
+     *         inserted
+     * @throws SOAPException if there is an error in creating the
+     *                       Attribute
+     */
+    public SOAPElement addAttribute(Name name, String value) throws SOAPException {
+        if (name.getURI() == null || name.getURI().trim().length() == 0) {
+            this.element.setAttribute(name.getLocalName(), value);
+        } else {
+            this.element.setAttributeNS(name.getURI(), name.getPrefix() + ":" + name.getLocalName(), value);
+        }
         return this;
     }
 
-    /**
-     * Method addAttribute
-     * This method adds an attribute to the underlying omElement datamember and returns ourselves
-     *
-     * @param name
-     * @param value
-     * @return ourself
-     * @throws SOAPException
-     * @see javax.xml.soap.SOAPElement#addAttribute(javax.xml.soap.Name, java.lang.String)
-     */
-    public SOAPElement addAttribute(Name name, String value)
-            throws SOAPException {
-        org.apache.axis2.om.OMNamespace omNS = org.apache.axis2.om.OMAbstractFactory.getOMFactory()
-                .createOMNamespace(name.getURI(), name.getPrefix());
-        omElement.declareNamespace(omNS);
-        //TODO:
-        //The namespace of the attribute must be within the scope of the SOAPElement
-        //That check should be performed here.
-        omElement.addAttribute(name.getLocalName(), value, omNS);
-        return this;
+    /* (non-Javadoc)
+      * @see javax.xml.soap.SOAPElement#addChildElement(javax.xml.soap.Name)
+      */
+    public SOAPElement addChildElement(Name name) throws SOAPException {
+        return this.addChildElement(name.getLocalName(), name.getPrefix(), name.getURI());
     }
 
-    /**
-     * Method addNamespaceDeclaration
-     *
-     * @param prefix
-     * @param uri
-     * @return
-     * @throws SOAPException
-     * @see javax.xml.soap.SOAPElement#addNamespaceDeclaration(java.lang.String, java.lang.String)
-     */
-    public SOAPElement addNamespaceDeclaration(String prefix, String uri)
-            throws SOAPException {
-        omElement.declareNamespace(uri, prefix);
-        return this;
+    /* (non-Javadoc)
+      * @see javax.xml.soap.SOAPElement#addChildElement(javax.xml.soap.SOAPElement)
+      */
+    public SOAPElement addChildElement(SOAPElement soapElement) throws SOAPException {
+        this.element.appendChild(soapElement);
+        return soapElement;
     }
 
-    /**
-     * Method getAttributeValue
-     *
-     * @param name
-     * @return
-     * @see javax.xml.soap.SOAPElement#getAttributeValue(javax.xml.soap.Name)
-     */
-    public String getAttributeValue(Name name) {
-        //This method is waiting on the finalization of the name for a method
-        //in OMElement that returns a OMAttribute from an input QName
-        return omElement.getAttribute(
-                new QName(name.getURI(),
-                        name.getLocalName(),
-                        name.getPrefix()))
-                .getAttributeValue();
+    /* (non-Javadoc)
+      * @see javax.xml.soap.SOAPElement#addChildElement(java.lang.String, java.lang.String, java.lang.String)
+      */
+    public SOAPElement addChildElement(String localName, String prefix, String uri) throws SOAPException {
+        this.element.declareNamespace(uri, prefix);
+        return this.addChildElement(localName, prefix);
     }
 
-    /**
-     * Method getAllAttributes
-     *
-     * @return
-     * @see javax.xml.soap.SOAPElement#getAllAttributes()
-     */
-    public Iterator getAllAttributes() {
-        Iterator attrIter = omElement.getAllAttributes();
-        ArrayList arrayList = new ArrayList();
-        while (attrIter.hasNext()) {
-            Object o = attrIter.next();
-            if (o instanceof org.apache.axis2.om.OMAttribute) {
-                //we need to create a SOAPNode for this and add to the arrayList
-                /*javax.xml.soap.Node soapNode = new NodeImpl(
-                        (org.apache.axis2.om.OMAttribute) o);
-                arrayList.add(soapNode);*/
-            	//We need to return javax.xml.soap.Name 
-                OMNamespace ons = ((org.apache.axis2.om.OMAttribute)o).getNamespace();
-                String lName = ((org.apache.axis2.om.OMAttribute)o).getLocalName();
-                arrayList.add(new PrefixedQName(ons.getName(), lName, ons.getPrefix()));
-            }
-        }
-        return arrayList.iterator();
+    /* (non-Javadoc)
+      * @see javax.xml.soap.SOAPElement#addChildElement(java.lang.String, java.lang.String)
+      */
+    public SOAPElement addChildElement(String localName, String prefix) throws SOAPException {
+        String namespaceURI = this.getNamespaceURI(prefix);
+
+        if (namespaceURI == null) {
+            throw new SOAPException("Namespace not declared for the give prefix: " + prefix);
+        }
+        SOAPElementImpl elem =
+                new SOAPElementImpl((ElementImpl) this.getOwnerDocument().createElementNS(namespaceURI,
+                                                                                          localName));
+        this.element.appendChild(elem.element);
+        return elem;
     }
 
-    /**
-     * Method getNamespaceURI
-     *
-     * @param prefix
-     * @return
-     * @see javax.xml.soap.SOAPElement#getNamespaceURI(java.lang.String)
-     */
-    public String getNamespaceURI(String prefix) {
-        //Lets get all the inscope namespaces of this SOAPElement and iterate over them,
-        //whenever the prefix mathces break and return the corresponding URI.
-        Iterator nsIter = omElement.getAllDeclaredNamespaces();
-
-        //loop over to see a prefix matching namespace.
-        while (nsIter.hasNext()) {
-            Object o = nsIter.next();
-            if (o instanceof org.apache.axis2.om.OMNamespace) {
-                org.apache.axis2.om.OMNamespace ns = (org.apache.axis2.om.OMNamespace) o;
-                if (ns.getPrefix().equalsIgnoreCase(prefix))
-                    return ns.getName();
-            }
-        }
-        return null;
+    /* (non-Javadoc)
+      * @see javax.xml.soap.SOAPElement#addChildElement(java.lang.String)
+      */
+    public SOAPElement addChildElement(String localName) throws SOAPException {
+        SOAPElementImpl elem = new SOAPElementImpl((ElementImpl) this.getOwnerDocument().createElement(localName));
+        this.element.appendChild(elem.element);
+        return elem;
     }
 
-    /**
-     * method getNamespacePrefixes
-     * This method returns an iterator over all the declared namespaces prefix names.
-     *
-     * @return Iterator
-     * @see javax.xml.soap.SOAPElement#getNamespacePrefixes()
-     */
-    public Iterator getNamespacePrefixes() {
-        //Get all declared namespace, make a list of their prefixes and return an iterator over that list
-        ArrayList prefixList = new ArrayList();
-        Iterator nsIter = omElement.getAllDeclaredNamespaces();
-        while (nsIter.hasNext()) {
-            Object o = nsIter.next();
-            if (o instanceof org.apache.axis2.om.OMNamespace) {
-                org.apache.axis2.om.OMNamespace ns = (org.apache.axis2.om.OMNamespace) o;
-                prefixList.add(ns.getPrefix());
-            }
-        }
-        return prefixList.iterator();
+    /* (non-Javadoc)
+      * @see javax.xml.soap.SOAPElement#addNamespaceDeclaration(java.lang.String, java.lang.String)
+      */
+    public SOAPElement addNamespaceDeclaration(String prefix, String uri) throws SOAPException {
+        this.element.declareNamespace(prefix, uri);
+        return this;
     }
 
     /**
-     * Method getElementName
+     * Creates a new <code>Text</code> object initialized with the given
+     * <code>String</code> and adds it to this <code>SOAPElement</code> object.
      *
-     * @return
-     * @see javax.xml.soap.SOAPElement#getElementName()
+     * @param text a <code>String</code> object with the textual content to be added
+     * @return the <code>SOAPElement</code> object into which
+     *         the new <code>Text</code> object was inserted
+     * @throws SOAPException if there is an error in creating the
+     *                       new <code>Text</code> object
      */
-    public Name getElementName() {
-        QName qName = omElement.getQName();
-        return new PrefixedQName(qName.getNamespaceURI(),
-                qName.getLocalPart(),
-                qName.getPrefix());
+    public SOAPElement addTextNode(String text) throws SOAPException {
+        //OmElement.setText() will remove all the other text nodes that it contains
+        //Therefore create a text node and add it
+        Text textNode = this.getOwnerDocument().createTextNode(text);
+        this.element.appendChild(textNode);
+        return this;
     }
 
     /**
-     * method removeAttribute
-     * This method removes an attribute with the specified name from the element.
-     * Returns true if the attribute was removed successfully; false if it was not
+     * Returns an iterator over all of the attribute names in
+     * this <CODE>SOAPElement</CODE> object. The iterator can be
+     * used to get the attribute names, which can then be passed to
+     * the method <CODE>getAttributeValue</CODE> to retrieve the
+     * value of each attribute.
      *
-     * @param name
-     * @return boolean
-     * @see javax.xml.soap.SOAPElement#removeAttribute(javax.xml.soap.Name)
+     * @return an iterator over the names of the attributes
      */
-    public boolean removeAttribute(Name name) {
-        //get the OMAttribute with the given Name first, and call a removeAttribute(OMAttribute)
-        //method on the omElement datamember this SOAPElement has in it.
-        org.apache.axis2.om.OMAttribute attr = omElement.getAttribute(
-                new QName(name.getURI(),
-                        name.getLocalName(),
-                        name.getPrefix()));
-        if (attr != null) {
-            omElement.removeAttribute(attr);
-            return true;
+    public Iterator getAllAttributes() {
+        final Iterator attribIter = this.element.getAllAttributes();
+        Collection attribName = new ArrayList();
+        Attr attr;
+        while (attribIter.hasNext()) {
+            attr = (Attr) attribIter.next();
+            PrefixedQName qname;
+            if (attr.getNamespaceURI() == null || attr.getNamespaceURI().trim().length() == 0) {
+                qname = new PrefixedQName(attr.getNamespaceURI(),
+                                          attr.getName(),
+                                          attr.getPrefix());
+            } else {
+                qname = new PrefixedQName(attr.getNamespaceURI(),
+                                          attr.getLocalName(),
+                                          attr.getPrefix());
+            }
+            attribName.add(qname);
         }
-        return false;
+        return attribName.iterator();
     }
 
-    /**
-     * method removeNamespaceDeclaration
-     *
-     * @param prefix
-     * @return
-     * @see javax.xml.soap.SOAPElement#removeNamespaceDeclaration(java.lang.String)
-     */
-    public boolean removeNamespaceDeclaration(String prefix) {
-        //TODO:
-        //I'm waiting on a removeNamespace method to be added to OMElement API
-        return false;
+    /* (non-Javadoc)
+      * @see javax.xml.soap.SOAPElement#getAttributeValue(javax.xml.soap.Name)
+      */
+    public String getAttributeValue(Name name) {
+        //This method is waiting on the finalization of the name for a method
+        //in OMElement that returns a OMAttribute from an input QName
+        final OMAttribute attribute = this.element.getAttribute(new QName(name.getURI(),
+                                                                          name.getLocalName(),
+                                                                          name.getPrefix()));
+        return attribute.getAttributeValue();
     }
 
     /**
-     * method getChildElements
+     * Returns an iterator over all the immediate content of
+     * this element. This includes <CODE>Text</CODE> objects as well
+     * as <CODE>SOAPElement</CODE> objects.
      *
-     * @return
-     * @see javax.xml.soap.SOAPElement#getChildElements()
+     * @return an iterator over <CODE>Text</CODE> and <CODE>SOAPElement</CODE>
+     *         contained within this <CODE>SOAPElement</CODE> object
      */
     public Iterator getChildElements() {
         //Actually all the children are being treated as OMNodes and are being
         //wrapped accordingly to a single type (SOAPElement) and being returned in an iterator.
         //Text nodes and element nodes are all being treated alike here. Is that a serious issue???
-        Iterator childIter = omElement.getChildren();
-        ArrayList arrayList = new ArrayList();
+
+        Iterator childIter = this.element.getChildren();
+        Collection childElements = new ArrayList();
         while (childIter.hasNext()) {
             Object o = childIter.next();
-            if (o instanceof org.apache.axis2.om.OMNode) {
-                if (o instanceof org.apache.axis2.om.OMText) {
-                    javax.xml.soap.Text childText = new TextImpl(
-                            ((org.apache.axis2.om.OMText) o).getText());
-                    arrayList.add(childText);
-                } else {
-                    SOAPElement childElement = new SOAPElementImpl(
-                            (org.apache.axis2.om.OMElement) o);
-                    arrayList.add(childElement);
-                }
-                //javax.xml.soap.Node childElement = new NodeImpl((org.apache.axis2.om.OMNode)o);
-
+            if (o instanceof Text) {
+                childElements.add(new TextImplEx(((Text) o).getData()));
+            } else {
+                childElements.add(new SOAPElementImpl((ElementImpl) o));
             }
         }
-        return arrayList.iterator();
+        return childElements.iterator();
     }
 
-    /**
-     * method getChildElements
-     *
-     * @param name
-     * @return
-     * @see javax.xml.soap.SOAPElement#getChildElements(javax.xml.soap.Name)
-     */
+    /* (non-Javadoc)
+      * @see javax.xml.soap.SOAPElement#getChildElements(javax.xml.soap.Name)
+      */
     public Iterator getChildElements(Name name) {
         QName qName = new QName(name.getURI(), name.getLocalName());
-        Iterator childIter = omElement.getChildrenWithName(qName);
+        Iterator childIter = this.element.getChildrenWithName(qName);
         ArrayList arrayList = new ArrayList();
         while (childIter.hasNext()) {
             Object o = childIter.next();
-            if (o instanceof org.apache.axis2.om.OMNode) {
-                SOAPElement childElement = new SOAPElementImpl(
-                        (org.apache.axis2.om.OMElement) o);
-                arrayList.add(childElement);
+            if (o instanceof javax.xml.soap.Node) {
+                arrayList.add(o);
             }
         }
         return arrayList.iterator();
     }
 
-    /**
-     * method setEncodingStyle
-     *
-     * @param encodingStyle
-     * @see javax.xml.soap.SOAPElement#setEncodingStyle(java.lang.String)
-     */
-    public void setEncodingStyle(String encodingStyle) throws SOAPException {
-
-        //TODO:
-        //Donno how to tackle this right now.
-        //Couldn't figure out corresponding functionality in OM
-        //Should re-visit
-
+    /* (non-Javadoc)
+      * @see javax.xml.soap.SOAPElement#getElementName()
+      */
+    public Name getElementName() {
+        QName qName = this.element.getQName();
+        return new PrefixedQName(qName.getNamespaceURI(),
+                                 qName.getLocalPart(),
+                                 qName.getPrefix());
     }
 
-    /**
-     * method getEncodingStyle
-     *
-     * @return
-     * @see javax.xml.soap.SOAPElement#getEncodingStyle()
-     */
+    /* (non-Javadoc)
+      * @see javax.xml.soap.SOAPElement#getEncodingStyle()
+      */
     public String getEncodingStyle() {
-        //TODO:
-        //This is incomplete, needs to be revisited later
-        return null;
+        return ((DocumentImpl) this.getOwnerDocument()).getCharsetEncoding();
     }
 
-    /**
-     * method removeContents
-     *
-     * @see javax.xml.soap.SOAPElement#removeContents()
-     */
-    public void removeContents() {
-        //We will get all the children and iteratively call the detach() on all of 'em.
-        Iterator childIter = omElement.getChildren();
-
-        while (childIter.hasNext()) {
-            Object o = childIter.next();
-            if (o instanceof org.apache.axis2.om.OMNode)
-                ((org.apache.axis2.om.OMNode) o).detach();
+    /* (non-Javadoc)
+      * @see javax.xml.soap.SOAPElement#getNamespacePrefixes()
+      */
+    public Iterator getNamespacePrefixes() {
+        //Get all declared namespace, make a list of their prefixes and return an iterator over that list
+        ArrayList prefixList = new ArrayList();
+        Iterator nsIter = this.element.getAllDeclaredNamespaces();
+        while (nsIter.hasNext()) {
+            Object o = nsIter.next();
+            if (o instanceof org.apache.axis2.om.OMNamespace) {
+                org.apache.axis2.om.OMNamespace ns = (org.apache.axis2.om.OMNamespace) o;
+                prefixList.add(ns.getPrefix());
+            }
         }
+        return prefixList.iterator();
     }
 
-    /**
-     * method getVisibleNamespacePrefixes
-     *
-     * @return
-     * @see javax.xml.soap.SOAPElement#getVisibleNamespacePrefixes()
-     */
+    /* (non-Javadoc)
+      * @see javax.xml.soap.SOAPElement#getNamespaceURI(java.lang.String)
+      */
+    public String getNamespaceURI(String prefix) {
+        return this.element.getNamespaceURI(prefix);
+    }
+
+    /* (non-Javadoc)
+      * @see javax.xml.soap.SOAPElement#getVisibleNamespacePrefixes()
+      */
     public Iterator getVisibleNamespacePrefixes() {
         //I'll recursively return all the declared namespaces till this node, including its parents etc.
-        Iterator namespacesIter = omElement.getAllDeclaredNamespaces();
+        Iterator namespacesIter = this.element.getAllDeclaredNamespaces();
         ArrayList returnList = new ArrayList();
         while (namespacesIter.hasNext()) {
             Object o = namespacesIter.next();
-            if (o instanceof org.apache.axis2.om.OMNamespace) {
-                javax.xml.soap.Node soapNode = new NodeImpl(
-                        (org.apache.axis2.om.OMNamespace) o);
-                returnList.add(soapNode);
+            if (o instanceof OMNamespace) {
+                OMNamespace ns = (OMNamespace) o;
+                if (ns.getPrefix() != null) {
+                    returnList.add(ns.getPrefix());
+                }
             }
-        }//taken care of adding namespaces of this node.
+        }
+        //taken care of adding namespaces of this node.
         //now we have to take care of adding the namespaces that are in the scope till the level of
         //this nodes' parent.
-        org.apache.axis2.om.OMContainer parent = omElement.getParent();
+        org.apache.axis2.om.OMContainer parent = this.element.getParent();
         if (parent != null && parent instanceof org.apache.axis2.om.OMElement) {
             Iterator parentScopeNamespacesIter = ((org.apache.axis2.om.OMElement) parent).getAllDeclaredNamespaces();
             while (parentScopeNamespacesIter.hasNext()) {
                 Object o = parentScopeNamespacesIter.next();
-                if (o instanceof org.apache.axis2.om.OMNamespace) {
-                    javax.xml.soap.Node soapNode = new NodeImpl(
-                            (org.apache.axis2.om.OMNamespace) o);
-                    returnList.add(soapNode);
+                if (o instanceof OMNamespace) {
+                    OMNamespace ns = (OMNamespace) o;
+                    if (ns.getPrefix() != null) {
+                        returnList.add(ns.getPrefix());
+                    }
                 }
             }
         }
         return returnList.iterator();
     }
 
-    /**
-     * method getTagName
-     *
-     * @return
-     * @see org.w3c.dom.Element#getTagName()
-     */
-    public String getTagName() {
-        return this.getLocalName();
+    /* (non-Javadoc)
+      * @see javax.xml.soap.SOAPElement#removeAttribute(javax.xml.soap.Name)
+      */
+    public boolean removeAttribute(Name name) {
+        org.apache.axis2.om.OMAttribute attr = element.getAttribute(new QName(name.getURI(),
+                                                                              name.getLocalName(),
+                                                                              name.getPrefix()));
+        if (attr != null) {
+            this.element.removeAttribute(attr);
+            return true;
+        }
+        return false;
     }
 
-    /**
-     * method removeAttribute
-     *
-     * @param arg0
-     * @see org.w3c.dom.Element#removeAttribute(java.lang.String)
-     */
-    public void removeAttribute(String localName) throws DOMException {
-        //just got a localName, so assuming the namespace to be that of element
-        Name elementQualifiedName = this.getElementName();
-        //now try to remove that Attribute from this SOAPElement
-        this.removeAttribute(
-                new PrefixedQName(elementQualifiedName.getURI(),
-                        localName,
-                        elementQualifiedName.getPrefix()));
-    }
+    /* (non-Javadoc)
+      * @see javax.xml.soap.SOAPElement#removeContents()
+      */
+    public void removeContents() {
+        //We will get all the children and iteratively call the detach() on all of 'em.
+        Iterator childIter = this.element.getChildren();
 
-    /**
-     * method hasAttribute
-     * This method returns true when an attribute with a given name is specified
-     * on this element, false otherwise.
-     *
-     * @param localName
-     * @return
-     * @see org.w3c.dom.Element#hasAttribute(java.lang.String)
-     */
-    public boolean hasAttribute(String localName) {
-        Iterator attrIter = omElement.getAllAttributes();
-        while (attrIter.hasNext()) {
-            org.apache.axis2.om.OMAttribute omAttr = (org.apache.axis2.om.OMAttribute) (attrIter.next());
-            if (omAttr.getLocalName().equals(localName)) {
-                return true;
-            }
+        while (childIter.hasNext()) {
+            Object o = childIter.next();
+            if (o instanceof org.apache.axis2.om.OMNode)
+                ((org.apache.axis2.om.OMNode) o).detach();
         }
-        return false;
     }
 
-    /**
-     * method getAttribute
-     * This method retrieves the value of an attribute having specified localname.
-     * In case of an element having multiple attributes with same localname but declared
-     * in different namespaces, use of this method is unadvised.
-     *
-     * @param name
-     * @return String
-     * @see org.w3c.dom.Element#getAttribute(java.lang.String)
-     */
+    /* (non-Javadoc)
+      * @see javax.xml.soap.SOAPElement#removeNamespaceDeclaration(java.lang.String)
+      */
+    public boolean removeNamespaceDeclaration(String prefix) {
+        return this.element.removeNamespace(prefix);
+    }
+
+    /* (non-Javadoc)
+      * @see javax.xml.soap.SOAPElement#setEncodingStyle(java.lang.String)
+      */
+    public void setEncodingStyle(String encodingStyle) throws SOAPException {
+        ((DocumentImpl) this.getOwnerDocument()).setCharsetEncoding(encodingStyle);
+    }
+
+    /* (non-Javadoc)
+      * @see org.apache.axis2.om.impl.OMNodeEx#setParent(org.apache.axis2.om.OMContainer)
+      */
+    public void setParent(OMContainer parentElement) {
+        this.element.setParent(parentElement);
+    }
+
+    /* (non-Javadoc)
+      * @see org.w3c.dom.Element#getAttribute(java.lang.String)
+      */
     public String getAttribute(String name) {
-        Iterator attrIter = omElement.getAllAttributes();
-        while (attrIter.hasNext()) {
-            org.apache.axis2.om.OMAttribute omAttr = (org.apache.axis2.om.OMAttribute) (attrIter.next());
-            if (omAttr.getLocalName().equals(name)) {
-                return omAttr.getAttributeValue();
-            }
-        }
-        return null;
+        return this.element.getAttribute(name);
     }
 
     /* (non-Javadoc)
-     * @see org.w3c.dom.Element#removeAttributeNS(java.lang.String, java.lang.String)
-     */
-    public void removeAttributeNS(String namespaceURI, String localName) throws DOMException {
-        Name name = new PrefixedQName(namespaceURI, localName, null);
-        this.removeAttribute(name);
+      * @see org.w3c.dom.Element#getAttributeNode(java.lang.String)
+      */
+    public Attr getAttributeNode(String name) {
+        return this.element.getAttributeNode(name);
     }
 
-    /**
-     * Method setAttribute
-     * This method creates and adds an attribute with the given localName and value
-     * into the underlying OM. It uses the namespace of omElement datamember of this SOAPElement for the
-     * newly added attribute.
-     *
-     * @param localName
-     * @param value
-     * @return
-     * @see org.w3c.dom.Element#setAttribute(java.lang.String, java.lang.String)
-     */
-    public void setAttribute(String localName, String value) throws DOMException {
-        //We will create a OMAttribute for the given input params, add it
-        //to the omElement datamemeber
-        org.apache.axis2.om.OMAttribute omAttr = org.apache.axis2.om.OMAbstractFactory.getOMFactory()
-                .createOMAttribute(localName, omElement.getNamespace(), value);
-        omElement.addAttribute(omAttr);
+    /* (non-Javadoc)
+      * @see org.w3c.dom.Element#getAttributeNodeNS(java.lang.String, java.lang.String)
+      */
+    public Attr getAttributeNodeNS(String namespaceURI, String localName) {
+        return this.element.getAttributeNodeNS(namespaceURI, localName);
     }
 
-    /**
-     * method hasAttributeNS
-     * This method returns true when an attribute with a given local name and
-     * namespace URI is specified on this element or has a default value, false
-     * otherwise.
-     *
-     * @param namespaceURI
-     * @param localName
-     * @return boolean
-     * @see org.w3c.dom.Element#hasAttributeNS(java.lang.String, java.lang.String)
-     */
-    public boolean hasAttributeNS(String namespaceURI, String localName) {
-        Iterator attrIter = omElement.getAllAttributes();
-        while (attrIter.hasNext()) {
-            org.apache.axis2.om.OMAttribute omAttr = (org.apache.axis2.om.OMAttribute) (attrIter.next());
-            if (omAttr.getLocalName().equals(localName) &&
-                    omAttr.getNamespace().getName().equals(namespaceURI)) {
-                return true;
-            }
-        }
-        return false;
+    /* (non-Javadoc)
+      * @see org.w3c.dom.Element#getAttributeNS(java.lang.String, java.lang.String)
+      */
+    public String getAttributeNS(String namespaceURI, String localName) {
+        return this.element.getAttributeNS(namespaceURI, localName);
     }
 
-    public TypeInfo getSchemaTypeInfo() {
-        return null;  
+    /* (non-Javadoc)
+      * @see org.w3c.dom.Element#getElementsByTagName(java.lang.String)
+      */
+    public NodeList getElementsByTagName(String name) {
+        return this.element.getElementsByTagName(name);
     }
 
-    public void setIdAttribute(String name, boolean isId) throws DOMException {
-        
+    /* (non-Javadoc)
+      * @see org.w3c.dom.Element#getElementsByTagNameNS(java.lang.String, java.lang.String)
+      */
+    public NodeList getElementsByTagNameNS(String namespaceURI, String localName) {
+        return this.element.getElementsByTagNameNS(namespaceURI, localName);
     }
 
-    public void setIdAttributeNS(String namespaceURI, String localName, boolean isId) throws DOMException {
-        
+    /* (non-Javadoc)
+      * @see org.w3c.dom.Element#getTagName()
+      */
+    public String getTagName() {
+        return this.element.getTagName();
     }
 
-    public void setIdAttributeNode(Attr idAttr, boolean isId) throws DOMException {
-        
+    /* (non-Javadoc)
+      * @see org.w3c.dom.Element#hasAttribute(java.lang.String)
+      */
+    public boolean hasAttribute(String name) {
+        return this.element.hasAttribute(name);
     }
 
-    /**
-     * method getAttributeNode
-     * This method retrieves an attribute node by the specified localname
-     *
-     * @param name
-     * @returns Attr
-     * @see org.w3c.dom.Element#getAttributeNode(java.lang.String)
-     */
-    public Attr getAttributeNode(String localName) {
-        Iterator attrIter = omElement.getAllAttributes();
-        while (attrIter.hasNext()) {
-            org.apache.axis2.om.OMAttribute omAttr = (org.apache.axis2.om.OMAttribute) (attrIter.next());
-            if (omAttr.getLocalName().equals(localName)) {
-                //So we have the right OMAttribute in hand.
-                //wrap it into a org.w3c.dom.Attr object and return
-                return (new org.apache.axis2.saaj.AttrImpl(omAttr, this));
-            }
-        }
-        return null;
+    /* (non-Javadoc)
+      * @see org.w3c.dom.Element#hasAttributeNS(java.lang.String, java.lang.String)
+      */
+    public boolean hasAttributeNS(String namespaceURI, String localName) {
+        return this.element.hasAttributeNS(namespaceURI, localName);
     }
 
-    /**
-     * method removeAttributeNode
-     * This method removes the specified attribute node from this element.
-     *
-     * @param Attr The attribute node that should be removed.
-     * @return Attr
-     *         The removed attribute node
-     * @see org.w3c.dom.Element#removeAttributeNode(org.w3c.dom.Attr)
-     */
-    public Attr removeAttributeNode(Attr oldAttr) throws DOMException {
-        //create a OMAttribute with the input object's localName, namespace (URI + prefix), value
-        //remove from underlying omElement such an attribute
-        //wrap the OMAttribute used for removing, into a dom Attr object and return.
-        org.apache.axis2.om.OMNamespace oldAttrNS = org.apache.axis2.om.OMAbstractFactory.getOMFactory()
-                .createOMNamespace(oldAttr.getNamespaceURI(),
-                        oldAttr.getPrefix());
-        org.apache.axis2.om.OMAttribute omAttr = org.apache.axis2.om.OMAbstractFactory.getOMFactory()
-                .createOMAttribute(oldAttr.getName(),
-                        oldAttrNS,
-                        oldAttr.getValue());
-        omElement.removeAttribute(omAttr);
-        return (new org.apache.axis2.saaj.AttrImpl(omAttr, this));
+    /* (non-Javadoc)
+      * @see org.w3c.dom.Element#removeAttribute(java.lang.String)
+      */
+    public void removeAttribute(String name) throws DOMException {
+        this.element.removeAttribute(name);
     }
 
-    /**
-     * Method setAttributeNode
-     * This method creates and adds an attribute corresponding to the supplied <code>Attr</code>
-     * object into the underlying OM. The attribute that gets added to OM is created against this.omElement's namespace
-     *
-     * @param attr - a dom Attr object
-     * @return Attr - a dom Attr object corresponding to the added attribute.
-     * @see org.w3c.dom.Element#setAttributeNode(org.w3c.dom.Attr)
-     */
+    /* (non-Javadoc)
+      * @see org.w3c.dom.Element#removeAttributeNode(org.w3c.dom.Attr)
+      */
+    public Attr removeAttributeNode(Attr attr) throws DOMException {
+        return this.element.removeAttributeNode(attr);
+    }
+
+    /* (non-Javadoc)
+      * @see org.w3c.dom.Element#removeAttributeNS(java.lang.String, java.lang.String)
+      */
+    public void removeAttributeNS(String namespaceURI, String localName) throws DOMException {
+        this.element.removeAttributeNS(namespaceURI, localName);
+    }
+
+    /* (non-Javadoc)
+      * @see org.w3c.dom.Element#setAttribute(java.lang.String, java.lang.String)
+      */
+    public void setAttribute(String name, String value) throws DOMException {
+        this.element.setAttribute(name, value);
+    }
+
+    /* (non-Javadoc)
+      * @see org.w3c.dom.Element#setAttributeNode(org.w3c.dom.Attr)
+      */
     public Attr setAttributeNode(Attr attr) throws DOMException {
-        //Create a OMAttribute out of the supplied Attr, add this to the
-        //omElement and now wrap the created OMAttribute into a Attr and return
-        org.apache.axis2.om.OMAttribute omAttr = org.apache.axis2.om.OMAbstractFactory.getOMFactory()
-                .createOMAttribute(attr.getName(),
-                        omElement.getNamespace(),
-                        attr.getValue());
-        omElement.addAttribute(omAttr);
-        return (new org.apache.axis2.saaj.AttrImpl(omAttr, this));
+        return this.element.setAttributeNode(attr);
     }
 
-    /**
-     * Method setAttributeNode
-     * This method creates and adds an attribute corresponding to the supplied <code>Attr</code>
-     * object into the underlying OM. The attribute added is created against it's own namespace
-     *
-     * @param attr - a dom Attr object
-     * @return Attr - a dom Attr object corresponding to the added attribute.
-     * @see org.w3c.dom.Element#setAttributeNodeNS(org.w3c.dom.Attr)
-     */
+    /* (non-Javadoc)
+      * @see org.w3c.dom.Element#setAttributeNodeNS(org.w3c.dom.Attr)
+      */
     public Attr setAttributeNodeNS(Attr attr) throws DOMException {
-        org.apache.axis2.om.OMNamespace attrNS = org.apache.axis2.om.OMAbstractFactory.getOMFactory()
-                .createOMNamespace(attr.getNamespaceURI(), attr.getPrefix());
-        org.apache.axis2.om.OMAttribute omAttr = org.apache.axis2.om.OMAbstractFactory.getOMFactory()
-                .createOMAttribute(attr.getName(), attrNS, attr.getValue());
-        omElement.addAttribute(omAttr);
-        return (new org.apache.axis2.saaj.AttrImpl(omAttr, this));
+        return this.element.setAttributeNodeNS(attr);
     }
 
-    /**
-     * Method getElementsByTagName
-     * Returns a NodeList of all the descendant Elements with the given local
-     * name, in the order in which they are encountered in a preorder traversal
-     * of this Element tree.
-     * Current SOAPElement MAY not feature in the returned NodeList, only
-     * the descendant elements matching the criterion should be added.
-     *
-     * @param localName
-     * @return NodeList
-     * @see org.w3c.dom.Element#getElementsByTagName(java.lang.String)
-     */
-    public NodeList getElementsByTagName(String localName) {
-        Iterator childIter = this.getChildElements();
-        NodeListImpl returnList;
-        if (childIter == null)
-            return null;
-        else {
-            returnList = new NodeListImpl();
-            while (childIter.hasNext()) {
-                NodeList list = getElementsByTagNamePreOrder(
-                        (SOAPElement) childIter.next(), localName);
-                //should *append* this list to the existing list. Remember, we are doing preorder
-                returnList.addNodeList(list);
-            }
-        }
-        return returnList;
+    /* (non-Javadoc)
+      * @see org.w3c.dom.Element#setAttributeNS(java.lang.String, java.lang.String, java.lang.String)
+      */
+    public void setAttributeNS(String namespaceURI, String qualifiedName, String value) throws DOMException {
+        this.element.setAttributeNS(namespaceURI, qualifiedName, value);
     }
 
-    private NodeList getElementsByTagNamePreOrder(SOAPElement child,
-                                                  String localName) {
-        NodeListImpl returnList = new NodeListImpl();
-        //We are doing preorder, so see if root itself is a match and place it first in the order
-        if (child.getLocalName().equals(localName)) {
-            //so this must be first in the returnList
-            returnList.addNode(child);
-        }
-        returnList.addNodeList(child.getElementsByTagName(localName));
-        return returnList;
+    /* (non-Javadoc)
+      * @see org.w3c.dom.Node#getNodeName()
+      */
+    public String getNodeName() {
+        return this.element.getNodeName();
+    }
+
+    /* (non-Javadoc)
+      * @see org.w3c.dom.Node#getNodeType()
+      */
+    public short getNodeType() {
+        return Node.ELEMENT_NODE;
+    }
+
+    public ElementImpl getElement() {
+        return element;
     }
 
     /**
-     * method getAttributeNS
-     * This method retrieves the value of the attribute matching the specified namespaceURI, and localName
+     * Returns the parent element of this <code>Node</code> object.
+     * This method can throw an <code>UnsupportedOperationException</code>
+     * if the tree is not kept in memory.
      *
-     * @param namespaceURI
-     * @param localName
-     * @return String
-     * @see org.w3c.dom.Element#getAttributeNS(java.lang.String, java.lang.String)
+     * @return the <code>SOAPElement</code> object that is the parent of
+     *         this <code>Node</code> object or <code>null</code> if this
+     *         <code>Node</code> object is root
+     * @throws UnsupportedOperationException if the whole tree is not kept in memory
+     * @see #setParentElement(javax.xml.soap.SOAPElement) setParentElement(javax.xml.soap.SOAPElement)
      */
-    public String getAttributeNS(String namespaceURI, String localName) {
-        Iterator attrIter = omElement.getAllAttributes();
-        while (attrIter.hasNext()) {
-            org.apache.axis2.om.OMAttribute omAttr = (org.apache.axis2.om.OMAttribute) (attrIter.next());
-            if (omAttr.getLocalName().equals(localName) &&
-                    omAttr.getNamespace().getName().equals(namespaceURI)) {
-                return omAttr.getAttributeValue();
-            }
-        }
-        return null;
+    public SOAPElement getParentElement() {
+        return (SOAPElement) this.element.getParent();
     }
 
+
     /**
-     * Method setAttributeNS
-     * This method creates and adds an attribute with the given namespaceURI, localName and value
-     * into the underlying OM.
-     *
-     * @param localName
-     * @param value
-     * @return
-     * @see org.w3c.dom.Element#setAttributeNS(java.lang.String, java.lang.String, java.lang.String)
+     * Find the Document that this Node belongs to (the document in
+     * whose context the Node was created). The Node may or may not
      */
-    public void setAttributeNS(String namespaceURI,
-                               String localName,
-                               String value)
-            throws DOMException {
-        //since no prefix is given, we create a OMNamespace with given URI and null prefix. How good is it???
-        org.apache.axis2.om.OMNamespace attrNS = org.apache.axis2.om.OMAbstractFactory.getOMFactory()
-                .createOMNamespace(namespaceURI, null);
-        org.apache.axis2.om.OMAttribute omAttr = org.apache.axis2.om.OMAbstractFactory.getOMFactory()
-                .createOMAttribute(localName, attrNS, value);
-        omElement.addAttribute(omAttr);
+    public Document getOwnerDocument() {
+        return this.element.getOwnerDocument();
     }
 
     /**
-     * method getAttributeNodeNS
-     * This method retrieves an org.w3c.dom.Attr node matching the specified namespaceURI and localName
+     * Returns the the value of the immediate child of this <code>Node</code>
+     * object if a child exists and its value is text.
      *
-     * @param namespaceURI
-     * @param localName
-     * @return Attr
-     * @see org.w3c.dom.Element#getAttributeNodeNS(java.lang.String, java.lang.String)
+     * @return a <code>String</code> with the text of the immediate child of
+     *         this <code>Node</code> object if (1) there is a child and
+     *         (2) the child is a <code>Text</code> object;
+     *         <code>null</code> otherwise
      */
-    public Attr getAttributeNodeNS(String namespaceURI, String localName) {
-        Iterator attrIter = omElement.getAllAttributes();
-        while (attrIter.hasNext()) {
-            org.apache.axis2.om.OMAttribute omAttr = (org.apache.axis2.om.OMAttribute) (attrIter.next());
-            if (omAttr.getLocalName().equals(localName) &&
-                    omAttr.getNamespace().getName().equals(namespaceURI)) {
-                return (new org.apache.axis2.saaj.AttrImpl(omAttr, this));
+    public String getValue() {
+
+        if (element.getType() == OMNode.TEXT_NODE) {
+            return element.getText();
+        } else if (element.getType() == OMNode.ELEMENT_NODE) {
+            final OMNode firstOMChild = element.getFirstOMChild();
+            if (firstOMChild instanceof TextImpl) {
+                return ((TextImpl) firstOMChild).getData();
+            } else {
+                return ((SOAPElementImpl) firstOMChild).getValue();
             }
         }
         return null;
     }
 
+
+    public org.w3c.dom.Node getFirstChild() {
+        return this.element.getFirstChild();
+    }
+
     /**
-     * getElementsByTagNameNS
-     * Returns a NodeList of all the descendant Elements with a given local
-     * name and namespace URI in the order in which they are encountered in a
-     * preorder traversal of this Element tree.
-     * Current SOAPElement MAY not feature in the returned NodeList, only
-     * the descendant elements matching the criterion should be added.
+     * Method getLastChild
      *
-     * @param namespaceURI
-     * @param localName
-     * @return NodeList
-     * @see org.w3c.dom.Element#getElementsByTagNameNS(java.lang.String, java.lang.String)
+     * @see org.w3c.dom.Node#getLastChild()
      */
-    public NodeList getElementsByTagNameNS(String namespaceURI,
-                                           String localName) {
-        Iterator childIter = this.getChildElements();
-        NodeListImpl returnList;
-        if (childIter == null)
-            return null;
-        else {
-            returnList = new NodeListImpl();
-            while (childIter.hasNext()) {
-                NodeList list = getElementsByTagNameNSPreOrder(
-                        (SOAPElement) childIter.next(),
-                        namespaceURI,
-                        localName);
-                //should *append* this list to the existing list. Remember, we are doing preorder
-                returnList.addNodeList(list);
-            }
-        }
-        return returnList;
+    public org.w3c.dom.Node getLastChild() {
+        return this.element.getLastChild();
     }
 
-    private NodeList getElementsByTagNameNSPreOrder(SOAPElement child,
-                                                    String namespaceURI,
-                                                    String localName) {
-        NodeListImpl returnList = new NodeListImpl();
-        //We are doing preorder, so see if root itself is a match and place it first in the order
-        if (child.getNamespaceURI().equals(namespaceURI) &&
-                child.getLocalName().equals(localName)) {
-            //so this must be first in the returnList
-            returnList.addNode(child);
-        }
-        returnList.addNodeList(
-                child.getElementsByTagNameNS(namespaceURI, localName));
-        return returnList;
+    /**
+     * dom Node method
+     */
+    public org.w3c.dom.Node getNextSibling() {
+        return this.element.getNextSibling();
     }
 
+    public Node getPreviousSibling() {
+        return this.element.getPreviousSibling();
+    }
+
+    public NodeList getChildNodes() {
+        return this.element.getChildNodes();
+    }
+
+    public boolean hasChildNodes() {
+        return this.element.hasChildNodes();
+    }
 }

Modified: webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/SOAPEnvelopeImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/SOAPEnvelopeImpl.java?rev=365487&r1=365486&r2=365487&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/SOAPEnvelopeImpl.java (original)
+++ webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/SOAPEnvelopeImpl.java Mon Jan  2 16:28:43 2006
@@ -1,77 +1,69 @@
-/*
- * Copyright 2004,2005 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+/*                                                                             
+ * Copyright 2004,2005 The Apache Software Foundation.                         
+ *                                                                             
+ * Licensed under the Apache License, Version 2.0 (the "License");             
+ * you may not use this file except in compliance with the License.            
+ * You may obtain a copy of the License at                                     
+ *                                                                             
+ *      http://www.apache.org/licenses/LICENSE-2.0                             
+ *                                                                             
+ * Unless required by applicable law or agreed to in writing, software         
+ * distributed under the License is distributed on an "AS IS" BASIS,           
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.    
+ * See the License for the specific language governing permissions and         
+ * limitations under the License.                                              
  */
 package org.apache.axis2.saaj;
 
-import org.apache.axis2.om.OMAbstractFactory;
-import org.apache.axis2.soap.SOAPFactory;
+import org.apache.axis2.om.impl.dom.DocumentImpl;
+import org.apache.axis2.om.impl.dom.ElementImpl;
+import org.apache.axis2.soap.impl.dom.soap11.SOAP11BodyImpl;
+import org.apache.axis2.soap.impl.dom.soap11.SOAP11HeaderImpl;
+import org.w3c.dom.Document;
 
 import javax.xml.soap.Name;
 import javax.xml.soap.SOAPBody;
-import javax.xml.soap.SOAPEnvelope;
 import javax.xml.soap.SOAPException;
 import javax.xml.soap.SOAPHeader;
 
-
 /**
- * Class SOAPEnvelopeImpl
+ * 
  */
-public class SOAPEnvelopeImpl extends SOAPElementImpl implements SOAPEnvelope {
+public class SOAPEnvelopeImpl extends SOAPElementImpl implements javax.xml.soap.SOAPEnvelope {
 
-    /**
-     * Field soSOAPEnvelope
-     * A data member of OM's SOAPEnvelopeImpl which would be used for delegation of any work to underlying OM.
-     */
     private org.apache.axis2.soap.SOAPEnvelope omSOAPEnvelope;
 
-    /**
-     * Constructor SOAPEnvelopeImpl
-     */
-    public SOAPEnvelopeImpl() {
-        //super(omEnv);
-        SOAPFactory fac = OMAbstractFactory.getSOAP11Factory();
-        omNode = omElement = omSOAPEnvelope = fac.getDefaultEnvelope();
+    public SOAPEnvelopeImpl(final org.apache.axis2.soap.SOAPEnvelope element) {
+        super((ElementImpl) element);
+        omSOAPEnvelope = element;
     }
 
-    public SOAPEnvelopeImpl(org.apache.axis2.soap.SOAPEnvelope omEnvelope) {
-        super(omEnvelope);
-        this.omSOAPEnvelope = omEnvelope;
+    public void setOwnerDocument(Document document) {
+        super.setOwnerDocument((DocumentImpl) document);
     }
 
-    /**
-     * method getOMEnvelope
-     *
-     * @return
-     */
     public org.apache.axis2.soap.SOAPEnvelope getOMEnvelope() {
         return omSOAPEnvelope;
     }
 
-
     /**
-     * method createName
-     *
-     * @param localName
-     * @param prefix
-     * @param uri
-     * @return
-     * @throws SOAPException
-     * @see javax.xml.soap.SOAPEnvelope#createName(java.lang.String, java.lang.String, java.lang.String)
+     * Creates a new <CODE>Name</CODE> object initialized with the
+     * given local name, namespace prefix, and namespace URI.
+     * <p/>
+     * <P>This factory method creates <CODE>Name</CODE> objects
+     * for use in the SOAP/XML document.
+     *
+     * @param localName a <CODE>String</CODE> giving
+     *                  the local name
+     * @param prefix    a <CODE>String</CODE> giving
+     *                  the prefix of the namespace
+     * @param uri       a <CODE>String</CODE> giving the
+     *                  URI of the namespace
+     * @return a <CODE>Name</CODE> object initialized with the given
+     *         local name, namespace prefix, and namespace URI
+     * @throws javax.xml.soap.SOAPException if there is a SOAP error
      */
-    public Name createName(String localName, String prefix, String uri)
-            throws SOAPException {
+    public Name createName(String localName, String prefix, String uri) throws SOAPException {
         try {
             return new PrefixedQName(uri, localName, prefix);
         } catch (Exception e) {
@@ -80,12 +72,17 @@
     }
 
     /**
-     * method createName
-     *
-     * @param localName
-     * @return
-     * @throws SOAPException
-     * @see javax.xml.soap.SOAPEnvelope#createName(java.lang.String)
+     * Creates a new <CODE>Name</CODE> object initialized with the
+     * given local name.
+     * <p/>
+     * <P>This factory method creates <CODE>Name</CODE> objects
+     * for use in the SOAP/XML document.
+     *
+     * @param localName a <CODE>String</CODE> giving
+     *                  the local name
+     * @return a <CODE>Name</CODE> object initialized with the given
+     *         local name
+     * @throws javax.xml.soap.SOAPException if there is a SOAP error
      */
     public Name createName(String localName) throws SOAPException {
         try {
@@ -96,99 +93,104 @@
     }
 
     /**
-     * method getHeader
-     *
-     * @return
-     * @throws SOAPException
-     * @see javax.xml.soap.SOAPEnvelope#getHeader()
+     * Returns the <CODE>SOAPHeader</CODE> object for this <CODE>
+     * SOAPEnvelope</CODE> object.
+     * <p/>
+     * <P>A new <CODE>SOAPMessage</CODE> object is by default
+     * created with a <CODE>SOAPEnvelope</CODE> object that
+     * contains an empty <CODE>SOAPHeader</CODE> object. As a
+     * result, the method <CODE>getHeader</CODE> will always
+     * return a <CODE>SOAPHeader</CODE> object unless the header
+     * has been removed and a new one has not been added.
+     *
+     * @return the <CODE>SOAPHeader</CODE> object or <CODE>
+     *         null</CODE> if there is none
+     * @throws javax.xml.soap.SOAPException if there is a problem
+     *                                      obtaining the <CODE>SOAPHeader</CODE> object
      */
     public SOAPHeader getHeader() throws SOAPException {
-
-        org.apache.axis2.soap.SOAPHeader omSOAPHeader;
-        try {
-            omSOAPHeader =
-                    omSOAPEnvelope.getHeader();
-        } catch (Exception e) {
-            throw new SOAPException(e);
+        org.apache.axis2.soap.SOAPHeader soapHeader = omSOAPEnvelope.getHeader();
+        if (soapHeader != null) {
+            return new SOAPHeaderImpl(soapHeader);
         }
-        if (omSOAPHeader != null)
-            return new SOAPHeaderImpl(omSOAPHeader);
-        else
-            return null;
+        return null;
     }
 
     /**
-     * method getBody
-     *
-     * @return
-     * @throws SOAPException
-     * @see javax.xml.soap.SOAPEnvelope#getBody()
-     */
-    public SOAPBody   getBody() throws SOAPException {
-
-        org.apache.axis2.soap.SOAPBody omSOAPBody = null;
-        try {
-            omSOAPBody = omSOAPEnvelope.getBody();
-        } catch (Exception e) {
-            //throw new SOAPException(e);
+     * Returns the <CODE>SOAPBody</CODE> object associated with
+     * this <CODE>SOAPEnvelope</CODE> object.
+     * <p/>
+     * <P>A new <CODE>SOAPMessage</CODE> object is by default
+     * created with a <CODE>SOAPEnvelope</CODE> object that
+     * contains an empty <CODE>SOAPBody</CODE> object. As a
+     * result, the method <CODE>getBody</CODE> will always return
+     * a <CODE>SOAPBody</CODE> object unless the body has been
+     * removed and a new one has not been added.
+     *
+     * @return the <CODE>SOAPBody</CODE> object for this <CODE>
+     *         SOAPEnvelope</CODE> object or <CODE>null</CODE> if there
+     *         is none
+     * @throws javax.xml.soap.SOAPException if there is a problem
+     *                                      obtaining the <CODE>SOAPBody</CODE> object
+     */
+    public SOAPBody getBody() throws SOAPException {
+        final org.apache.axis2.soap.SOAPBody body = omSOAPEnvelope.getBody();
+        if (body != null) {
+            return new SOAPBodyImpl(body);
         }
-        if (omSOAPBody != null)
-            return (new SOAPBodyImpl(omSOAPBody));
-        else
-            return null;
+        return null;
     }
 
     /**
-     * method addHeaderBlock
-     *
-     * @return
-     * @throws SOAPException
-     * @see javax.xml.soap.SOAPEnvelope#addHeader()
+     * Creates a <CODE>SOAPHeader</CODE> object and sets it as the
+     * <CODE>SOAPHeader</CODE> object for this <CODE>
+     * SOAPEnvelope</CODE> object.
+     * <p/>
+     * <P>It is illegal to add a header when the envelope already
+     * contains a header. Therefore, this method should be called
+     * only after the existing header has been removed.
+     *
+     * @return the new <CODE>SOAPHeader</CODE> object
+     * @throws javax.xml.soap.SOAPException if this <CODE>
+     *                                      SOAPEnvelope</CODE> object already contains a valid
+     *                                      <CODE>SOAPHeader</CODE> object
      */
     public SOAPHeader addHeader() throws SOAPException {
-        /*
-         * Our objective is to set the omSOAPHeader of the omSOAPEnvelope if not already present
-         */
-        try {
-            org.apache.axis2.soap.SOAPHeader header = omSOAPEnvelope.getHeader();
-            if (header == null) {
-                SOAPFactory soapFactory = OMAbstractFactory.getSOAP11Factory();
-                header = soapFactory.createSOAPHeader(omSOAPEnvelope);
-                omSOAPEnvelope.addChild(header);
-                return (new SOAPHeaderImpl(header));
-            } else {
-                throw new SOAPException(
-                        "Header already present, can't set body again without deleting the existing header");
-            }
-        } catch (Exception e) {
-            throw new SOAPException(e);
+
+        org.apache.axis2.soap.SOAPHeader header = omSOAPEnvelope.getHeader();
+        if (header == null) {
+            header = new SOAP11HeaderImpl(omSOAPEnvelope);
+            omSOAPEnvelope.addChild(header);
+            return (new SOAPHeaderImpl(header));
+        } else {
+            throw new SOAPException("Header already present, can't set header again without " +
+                                    "deleting the existing header.");
         }
     }
 
     /**
-     * method addBody
-     *
-     * @return
-     * @throws SOAPException
-     * @see javax.xml.soap.SOAPEnvelope#addBody()
+     * Creates a <CODE>SOAPBody</CODE> object and sets it as the
+     * <CODE>SOAPBody</CODE> object for this <CODE>
+     * SOAPEnvelope</CODE> object.
+     * <p/>
+     * <P>It is illegal to add a body when the envelope already
+     * contains a body. Therefore, this method should be called
+     * only after the existing body has been removed.
+     *
+     * @return the new <CODE>SOAPBody</CODE> object
+     * @throws javax.xml.soap.SOAPException if this <CODE>
+     *                                      SOAPEnvelope</CODE> object already contains a valid
+     *                                      <CODE>SOAPBody</CODE> object
      */
     public SOAPBody addBody() throws SOAPException {
-        /*
-         * Our objective is to set the omSOAPBody of the omSOAPEnvelope if not already present
-         */
-        try {
-            org.apache.axis2.soap.SOAPBody body = omSOAPEnvelope.getBody();
-            if (body == null) {
-                SOAPFactory soapFactory = OMAbstractFactory.getSOAP11Factory();
-                body = soapFactory.createSOAPBody(omSOAPEnvelope);
-                omSOAPEnvelope.addChild(body);
-                return (new SOAPBodyImpl(body));
-            } else {
-                throw new SOAPException(
-                        "Body already present, can't set body again without deleting the existing body");
-            }
-        } catch (Exception e) {
-            throw new SOAPException(e);
+        org.apache.axis2.soap.SOAPBody body = omSOAPEnvelope.getBody();
+        if (body == null) {
+            body = new SOAP11BodyImpl(omSOAPEnvelope);
+            omSOAPEnvelope.addChild(body);
+            return (new SOAPBodyImpl(body));
+        } else {
+            throw new SOAPException("Body already present, can't set body again without " +
+                                    "deleting the existing body.");
         }
     }
 

Modified: webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/SOAPFactoryImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/SOAPFactoryImpl.java?rev=365487&r1=365486&r2=365487&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/SOAPFactoryImpl.java (original)
+++ webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/SOAPFactoryImpl.java Mon Jan  2 16:28:43 2006
@@ -1,87 +1,143 @@
-/*
- * Copyright 2004,2005 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+/*                                                                             
+ * Copyright 2004,2005 The Apache Software Foundation.                         
+ *                                                                             
+ * Licensed under the Apache License, Version 2.0 (the "License");             
+ * you may not use this file except in compliance with the License.            
+ * You may obtain a copy of the License at                                     
+ *                                                                             
+ *      http://www.apache.org/licenses/LICENSE-2.0                             
+ *                                                                             
+ * Unless required by applicable law or agreed to in writing, software         
+ * distributed under the License is distributed on an "AS IS" BASIS,           
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.    
+ * See the License for the specific language governing permissions and         
+ * limitations under the License.                                              
  */
 package org.apache.axis2.saaj;
 
-import org.apache.axis2.om.OMAbstractFactory;
+import org.apache.axis2.om.DOOMAbstractFactory;
 import org.apache.axis2.om.OMElement;
 import org.apache.axis2.om.OMNamespace;
+import org.apache.axis2.om.impl.dom.ElementImpl;
+import org.apache.axis2.om.impl.dom.factory.OMDOMFactory;
 
 import javax.xml.soap.Detail;
 import javax.xml.soap.Name;
 import javax.xml.soap.SOAPElement;
 import javax.xml.soap.SOAPException;
+import javax.xml.soap.SOAPFactory;
 
-public class SOAPFactoryImpl extends javax.xml.soap.SOAPFactory {
+/**
+ * 
+ */
+public class SOAPFactoryImpl extends SOAPFactory {
 
     /**
-     * @see javax.xml.soap.SOAPFactory#createElement(javax.xml.soap.Name)
+     * Create a <code>SOAPElement</code> object initialized with the
+     * given <code>Name</code> object.
+     *
+     * @param name a <code>Name</code> object with the XML name for
+     *             the new element
+     * @return the new <code>SOAPElement</code> object that was
+     *         created
+     * @throws javax.xml.soap.SOAPException if there is an error in creating the
+     *                                      <code>SOAPElement</code> object
      */
     public SOAPElement createElement(Name name) throws SOAPException {
-    	String localName = name.getLocalName();
-    	String prefix = name.getPrefix();
-    	String uri = name.getURI();
-    	OMElement newOMElement = OMAbstractFactory.getOMFactory()
-        .createOMElement(localName, uri, prefix);
-    	return new SOAPElementImpl(newOMElement);
+        String localName = name.getLocalName();
+        String prefix = name.getPrefix();
+        String uri = name.getURI();
+        OMElement omElement = DOOMAbstractFactory.getOMFactory().createOMElement(localName, uri, prefix);
+        return new SOAPElementImpl((ElementImpl) omElement);
     }
 
     /**
-     * @see javax.xml.soap.SOAPFactory#createElement(java.lang.String)
+     * Create a <code>SOAPElement</code> object initialized with the
+     * given local name.
+     *
+     * @param localName a <code>String</code> giving the local name for
+     *                  the new element
+     * @return the new <code>SOAPElement</code> object that was
+     *         created
+     * @throws javax.xml.soap.SOAPException if there is an error in creating the
+     *                                      <code>SOAPElement</code> object
      */
     public SOAPElement createElement(String localName) throws SOAPException {
-    	OMNamespace ns = OMAbstractFactory.getOMFactory()
-    	.createOMNamespace(null, null);
-    	OMElement newOMElement = OMAbstractFactory.getOMFactory()
-        .createOMElement(localName, ns);
-    	return new SOAPElementImpl(newOMElement);
+        OMDOMFactory omdomFactory = (OMDOMFactory) DOOMAbstractFactory.getOMFactory();
+
+        OMNamespace ns = omdomFactory.createOMNamespace(null, null);
+        OMElement omElement = omdomFactory.createOMElement(localName, ns);
+        return new SOAPElementImpl((ElementImpl) omElement);
     }
 
     /**
-     * @see javax.xml.soap.SOAPFactory#createElement(java.lang.String, java.lang.String, java.lang.String)
-     */
-    public SOAPElement createElement(String localName,
-                                     String prefix,
-                                     String uri)
-            throws SOAPException {
-        OMElement newOMElement = OMAbstractFactory.getOMFactory()
-                .createOMElement(localName, uri, prefix);
-        return new SOAPElementImpl(newOMElement);
+     * Create a new <code>SOAPElement</code> object with the given
+     * local name, prefix and uri.
+     *
+     * @param localName a <code>String</code> giving the local name
+     *                  for the new element
+     * @param prefix    the prefix for this <code>SOAPElement</code>
+     * @param uri       a <code>String</code> giving the URI of the
+     *                  namespace to which the new element belongs
+     * @return the new <code>SOAPElement</code> object that was
+     *         created
+     * @throws javax.xml.soap.SOAPException if there is an error in creating the
+     *                                      <code>SOAPElement</code> object
+     */
+    public SOAPElement createElement(String localName, String prefix, String uri) throws SOAPException {
+        OMElement omElement = DOOMAbstractFactory.getOMFactory().createOMElement(localName, uri, prefix);
+        return new SOAPElementImpl((ElementImpl) omElement);
     }
 
     /**
-     * @see javax.xml.soap.SOAPFactory#createDetail()
+     * Creates a new <code>Detail</code> object which serves as a container
+     * for <code>DetailEntry</code> objects.
+     * <p/>
+     * This factory method creates <code>Detail</code> objects for use in
+     * situations where it is not practical to use the <code>SOAPFault</code>
+     * abstraction.
+     *
+     * @return a <code>Detail</code> object
+     * @throws javax.xml.soap.SOAPException if there is a SOAP error
      */
     public Detail createDetail() throws SOAPException {
-        // TODO Auto-generated method stub
+        //TODO: Method implementation
         return null;
     }
 
     /**
-     * @see javax.xml.soap.SOAPFactory#createName(java.lang.String, java.lang.String, java.lang.String)
+     * Creates a new <code>Name</code> object initialized with the
+     * given local name, namespace prefix, and namespace URI.
+     * <p/>
+     * This factory method creates <code>Name</code> objects for use in
+     * situations where it is not practical to use the <code>SOAPEnvelope</code>
+     * abstraction.
+     *
+     * @param localName a <code>String</code> giving the local name
+     * @param prefix    a <code>String</code> giving the prefix of the namespace
+     * @param uri       a <code>String</code> giving the URI of the namespace
+     * @return a <code>Name</code> object initialized with the given
+     *         local name, namespace prefix, and namespace URI
+     * @throws javax.xml.soap.SOAPException if there is a SOAP error
      */
-    public Name createName(String localName, String prefix, String uri)
-            throws SOAPException {
+    public Name createName(String localName, String prefix, String uri) throws SOAPException {
         return new PrefixedQName(uri, localName, prefix);
     }
 
     /**
-     * @see javax.xml.soap.SOAPFactory#createName(java.lang.String)
+     * Creates a new <code>Name</code> object initialized with the
+     * given local name.
+     * <p/>
+     * This factory method creates <code>Name</code> objects for use in
+     * situations where it is not practical to use the <code>SOAPEnvelope</code>
+     * abstraction.
+     *
+     * @param localName a <code>String</code> giving the local name
+     * @return a <code>Name</code> object initialized with the given
+     *         local name
+     * @throws javax.xml.soap.SOAPException if there is a SOAP error
      */
     public Name createName(String localName) throws SOAPException {
-    	return new PrefixedQName(null, localName, null);
+        return new PrefixedQName(null, localName, null);
     }
-
 }

Modified: webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/SOAPFaultElementImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/SOAPFaultElementImpl.java?rev=365487&r1=365486&r2=365487&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/SOAPFaultElementImpl.java (original)
+++ webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/SOAPFaultElementImpl.java Mon Jan  2 16:28:43 2006
@@ -15,14 +15,18 @@
  */
 package org.apache.axis2.saaj;
 
+import org.apache.axis2.om.impl.dom.ElementImpl;
+
 import javax.xml.soap.SOAPFaultElement;
 
-/**
- * Class SOAPFaultElementImpl
- * Just a placeholder, extends SOAPElementImpl
- * Does not implement any new methods or override anything
- */
 public class SOAPFaultElementImpl extends SOAPElementImpl implements
-        SOAPFaultElement {
+                                                          SOAPFaultElement {
+
+    /**
+     * @param element
+     */
+    public SOAPFaultElementImpl(ElementImpl element) {
+        super(element);
+    }
 
 }