You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ws.apache.org by ve...@apache.org on 2015/06/20 21:09:07 UTC

svn commit: r1686664 [1/2] - in /webservices/axiom/trunk: ./ aspects/core-aspects/src/main/java/org/apache/axiom/core/ aspects/dom-aspects/src/main/java/org/apache/axiom/dom/ aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/ aspects/om-...

Author: veithen
Date: Sat Jun 20 19:09:06 2015
New Revision: 1686664

URL: http://svn.apache.org/r1686664
Log:
Reintegrate branch attr-aspects. This unifies attribute and namespace declaration handling in LLOM and DOOM. Attribute and namespace declarations are now stored in a simple linked list and the code is shared between LLOM and DOOM.

Added:
    webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/AttributeIterator.java
      - copied unchanged from r1686663, webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/AttributeIterator.java
    webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/AttributeMatcher.java
      - copied unchanged from r1686663, webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/AttributeMatcher.java
    webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreElementSupport.aj
      - copied unchanged from r1686663, webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreElementSupport.aj
    webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreModelException.java
      - copied unchanged from r1686663, webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreModelException.java
    webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreNSAwareAttribute.java
      - copied unchanged from r1686663, webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreNSAwareAttribute.java
    webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreNSAwareElement.java
      - copied unchanged from r1686663, webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreNSAwareElement.java
    webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreNSAwareElementSupport.aj
      - copied unchanged from r1686663, webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreNSAwareElementSupport.aj
    webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreNSAwareNamedNode.java
      - copied unchanged from r1686663, webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreNSAwareNamedNode.java
    webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreNSUnawareAttribute.java
      - copied unchanged from r1686663, webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreNSUnawareAttribute.java
    webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreNSUnawareNamedNode.java
      - copied unchanged from r1686663, webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreNSUnawareNamedNode.java
    webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreNSUnawareNamedNodeSupport.aj
      - copied unchanged from r1686663, webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreNSUnawareNamedNodeSupport.aj
    webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreNamespaceDeclaration.java
      - copied unchanged from r1686663, webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreNamespaceDeclaration.java
    webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreTypedAttribute.java
      - copied unchanged from r1686663, webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreTypedAttribute.java
    webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreTypedAttributeSupport.aj
      - copied unchanged from r1686663, webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreTypedAttributeSupport.aj
    webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/IdentityMapper.java
      - copied unchanged from r1686663, webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/IdentityMapper.java
    webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/Mapper.java
      - copied unchanged from r1686663, webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/Mapper.java
    webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/NSAwareAttributeMatcher.java
      - copied unchanged from r1686663, webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/NSAwareAttributeMatcher.java
    webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/NodeInUseException.java
      - copied unchanged from r1686663, webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/NodeInUseException.java
    webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/NodeMigrationException.java
      - copied unchanged from r1686663, webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/NodeMigrationException.java
    webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/NodeMigrationPolicy.java
      - copied unchanged from r1686663, webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/NodeMigrationPolicy.java
    webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/WrongDocumentException.java
      - copied unchanged from r1686663, webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/WrongDocumentException.java
    webservices/axiom/trunk/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/AttributesNamedNodeMap.java
      - copied unchanged from r1686663, webservices/axiom/branches/attrs-aspects/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/AttributesNamedNodeMap.java
    webservices/axiom/trunk/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/DOMNSUnawareAttribute.java
      - copied unchanged from r1686663, webservices/axiom/branches/attrs-aspects/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/DOMNSUnawareAttribute.java
    webservices/axiom/trunk/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/DOMNSUnawareAttributeSupport.aj
      - copied unchanged from r1686663, webservices/axiom/branches/attrs-aspects/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/DOMNSUnawareAttributeSupport.aj
    webservices/axiom/trunk/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/DOMNSUnawareNamedNode.java
      - copied unchanged from r1686663, webservices/axiom/branches/attrs-aspects/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/DOMNSUnawareNamedNode.java
    webservices/axiom/trunk/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/DOMNSUnawareNamedNodeSupport.aj
      - copied unchanged from r1686663, webservices/axiom/branches/attrs-aspects/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/DOMNSUnawareNamedNodeSupport.aj
    webservices/axiom/trunk/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/DOMNamespaceDeclaration.java
      - copied unchanged from r1686663, webservices/axiom/branches/attrs-aspects/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/DOMNamespaceDeclaration.java
    webservices/axiom/trunk/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/DOMNamespaceDeclarationSupport.aj
      - copied unchanged from r1686663, webservices/axiom/branches/attrs-aspects/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/DOMNamespaceDeclarationSupport.aj
    webservices/axiom/trunk/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/NSUtil.java
      - copied unchanged from r1686663, webservices/axiom/branches/attrs-aspects/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/NSUtil.java
    webservices/axiom/trunk/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/Policies.java
      - copied unchanged from r1686663, webservices/axiom/branches/attrs-aspects/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/Policies.java
    webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/AxiomExceptionUtil.java
      - copied unchanged from r1686663, webservices/axiom/branches/attrs-aspects/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/AxiomExceptionUtil.java
    webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/AxiomNamespaceDeclaration.java
      - copied unchanged from r1686663, webservices/axiom/branches/attrs-aspects/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/AxiomNamespaceDeclaration.java
    webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/AxiomNamespaceDeclarationSupport.aj
      - copied unchanged from r1686663, webservices/axiom/branches/attrs-aspects/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/AxiomNamespaceDeclarationSupport.aj
    webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/NamespaceDeclarationMapper.java
      - copied unchanged from r1686663, webservices/axiom/branches/attrs-aspects/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/NamespaceDeclarationMapper.java
    webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/Policies.java
      - copied unchanged from r1686663, webservices/axiom/branches/attrs-aspects/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/Policies.java
    webservices/axiom/trunk/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/NSAwareAttribute.java
      - copied unchanged from r1686663, webservices/axiom/branches/attrs-aspects/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/NSAwareAttribute.java
    webservices/axiom/trunk/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/NSUnawareAttribute.java
      - copied unchanged from r1686663, webservices/axiom/branches/attrs-aspects/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/NSUnawareAttribute.java
    webservices/axiom/trunk/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/NamespaceDeclaration.java
      - copied unchanged from r1686663, webservices/axiom/branches/attrs-aspects/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/NamespaceDeclaration.java
    webservices/axiom/trunk/implementations/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/Attribute.java
      - copied unchanged from r1686663, webservices/axiom/branches/attrs-aspects/implementations/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/Attribute.java
    webservices/axiom/trunk/implementations/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/NamespaceDeclaration.java
      - copied unchanged from r1686663, webservices/axiom/branches/attrs-aspects/implementations/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/NamespaceDeclaration.java
Removed:
    webservices/axiom/trunk/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/AttributeMap.java
    webservices/axiom/trunk/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/NSDeclIterator.java
Modified:
    webservices/axiom/trunk/   (props changed)
    webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreAttribute.java
    webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreAttributeSupport.aj
    webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreChildNode.java
    webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreChildNodeSupport.aj
    webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreElement.java
    webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/NodeFactory.java
    webservices/axiom/trunk/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/DOMDocumentSupport.aj
    webservices/axiom/trunk/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/DOMElementSupport.aj
    webservices/axiom/trunk/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/DOMExceptionUtil.java
    webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/AxiomAttribute.java
    webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/AxiomAttributeSupport.aj
    webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/AxiomElement.java
    webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/AxiomElementSupport.aj
    webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/AxiomNamedInformationItem.java
    webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/AxiomNamedInformationItemSupport.aj
    webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/factory/AxiomNodeFactory.java
    webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/serializer/pull/Navigator.java
    webservices/axiom/trunk/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/AttrImpl.java
    webservices/axiom/trunk/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DocumentImpl.java
    webservices/axiom/trunk/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ElementImpl.java
    webservices/axiom/trunk/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/NamedNodeSupport.aj
    webservices/axiom/trunk/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/factory/OMDOMFactory.java
    webservices/axiom/trunk/implementations/axiom-dom/src/main/java/org/apache/axiom/soap/impl/dom/SOAPHeaderBlockImpl.java
    webservices/axiom/trunk/implementations/axiom-dom/src/main/java/org/apache/axiom/soap/impl/dom/soap12/SOAP12FaultTextImpl.java
    webservices/axiom/trunk/implementations/axiom-dom/src/test/java/org/apache/axiom/om/impl/dom/DOMImplementationTest.java
    webservices/axiom/trunk/implementations/axiom-dom/src/test/java/org/apache/axiom/om/impl/dom/OMImplementationTest.java
    webservices/axiom/trunk/implementations/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMAttributeImpl.java
    webservices/axiom/trunk/implementations/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMElementImpl.java
    webservices/axiom/trunk/implementations/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMSourcedElementImpl.java
    webservices/axiom/trunk/implementations/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/PushOMBuilder.java
    webservices/axiom/trunk/implementations/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/factory/OMLinkedListImplFactory.java

Propchange: webservices/axiom/trunk/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sat Jun 20 19:09:06 2015
@@ -8,5 +8,6 @@
 /webservices/axiom/branches/CLONE:1337822-1339011
 /webservices/axiom/branches/CLONE_NODE:1346607-1353106
 /webservices/axiom/branches/JAXB2_DS:1366463-1367737
+/webservices/axiom/branches/attrs-aspects:1685218-1686663
 /webservices/axiom/branches/namespaceURIInterning:1293148-1293587
 /webservices/axiom/branches/osgi-redesign:1180368-1180596

Modified: webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreAttribute.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreAttribute.java?rev=1686664&r1=1686663&r2=1686664&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreAttribute.java (original)
+++ webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreAttribute.java Sat Jun 20 19:09:06 2015
@@ -19,5 +19,55 @@
 package org.apache.axiom.core;
 
 public interface CoreAttribute extends CoreNode {
+    /**
+     * Get the owner element of this attribute.
+     * 
+     * @return the owner element of the attribute
+     */
+    CoreElement coreGetOwnerElement();
     
+    /**
+     * Check if this node has an owner element.
+     * 
+     * @return <code>true</code> if and only if this node currently has an owner element
+     */
+    boolean coreHasOwnerElement();
+    
+    /**
+     * Remove this attribute from its owner element. The attribute will keep its current owner
+     * document.
+     * 
+     * @return <code>true</code> if the attribute had an owner element and has been removed from
+     *         that element; <code>false</code> if the attribute didn't have an owner element and no
+     *         changes have been made
+     */
+    boolean coreRemove();
+    
+    /**
+     * Remove this attribute from its owner element and assign it to a new owner document. The owner
+     * document will always be changed, even if the attribute has no owner element.
+     * 
+     * @return <code>true</code> if the attribute had an owner element and has been removed from
+     *         that element; <code>false</code> if the attribute didn't have an owner element
+     */
+    boolean coreRemove(CoreDocument document);
+    
+    /**
+     * Get the attribute immediately following the current attribute.
+     * 
+     * @return the next attribute, or <code>null</code> if the attribute is the last attribute of
+     *         its owner element or if the attribute has no owner element
+     */
+    CoreAttribute coreGetNextAttribute();
+    
+    /**
+     * Get the attribute immediately preceding the current attribute.
+     * 
+     * @return the previous attribute, or <code>null</code> if the attribute is the first attribute
+     *         of its owner element or if the attribute has no owner element
+     */
+    CoreAttribute coreGetPreviousAttribute();
+
+    String coreGetValue();
+    void coreSetValue(String value);
 }

Modified: webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreAttributeSupport.aj
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreAttributeSupport.aj?rev=1686664&r1=1686663&r2=1686664&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreAttributeSupport.aj (original)
+++ webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreAttributeSupport.aj Sat Jun 20 19:09:06 2015
@@ -24,11 +24,17 @@ public aspect CoreAttributeSupport {
      * to an element, or a {@link CoreElement} if the attribute has been added to an element.
      */
     private CoreParentNode CoreAttribute.owner;
+    
+    private CoreAttribute CoreAttribute.nextAttribute;
 
     public final CoreElement CoreAttribute.coreGetOwnerElement() {
         return owner instanceof CoreElement ? (CoreElement)owner : null;
     }
 
+    public final boolean CoreAttribute.coreHasOwnerElement() {
+        return owner instanceof CoreElement;
+    }
+
     public final void CoreAttribute.internalSetOwnerElement(CoreElement element) {
         if (element == null) {
             throw new IllegalArgumentException();
@@ -56,6 +62,68 @@ public aspect CoreAttributeSupport {
         owner = document;
     }
 
+    public final CoreAttribute CoreAttribute.coreGetNextAttribute() {
+        return nextAttribute;
+    }
+
+    public final void CoreAttribute.internalSetNextAttribute(CoreAttribute nextAttribute) {
+        this.nextAttribute = nextAttribute;
+    }
+    
+    public final CoreAttribute CoreAttribute.coreGetPreviousAttribute() {
+        if (owner instanceof CoreElement) {
+            CoreElement ownerElement = (CoreElement)owner;
+            CoreAttribute previousAttr = ownerElement.coreGetFirstAttribute();
+            while (previousAttr != null) {
+                CoreAttribute nextAttr = previousAttr.nextAttribute;
+                if (nextAttr == this) {
+                    break;
+                }
+                previousAttr = nextAttr;
+            }
+            return previousAttr;
+        } else {
+            return null;
+        }
+    }
+
+    final void CoreAttribute.insertAttributeAfter(CoreAttribute attr) {
+        // TODO: throw exception if attribute already has an owner
+        attr.internalSetOwnerElement(coreGetOwnerElement());
+        if (nextAttribute != null) {
+            attr.nextAttribute = nextAttribute;
+        }
+        nextAttribute = attr;
+    }
+
+    public final boolean CoreAttribute.coreRemove() {
+        return remove(false, null);
+    }
+
+    public final boolean CoreAttribute.coreRemove(CoreDocument document) {
+        return remove(true, document);
+    }
+
+    private boolean CoreAttribute.remove(boolean newOwnerDocument, CoreDocument ownerDocument) {
+        if (owner instanceof CoreElement) {
+            CoreElement ownerElement = (CoreElement)owner;
+            CoreAttribute previousAttr = coreGetPreviousAttribute();
+            owner = newOwnerDocument ? ownerDocument : coreGetOwnerDocument(false); // TODO: create?
+            if (previousAttr == null) {
+                ownerElement.internalSetFirstAttribute(nextAttribute);
+            } else {
+                previousAttr.nextAttribute = nextAttribute;
+            }
+            nextAttribute = null;
+            return true;
+        } else {
+            if (newOwnerDocument) {
+                owner = ownerDocument;
+            }
+            return false;
+        }
+    }
+
     public final boolean CoreAttribute.coreGetSpecified() {
         return !getFlag(Flags.DEFAULT_ATTR);
     }

Modified: webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreChildNode.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreChildNode.java?rev=1686664&r1=1686663&r2=1686664&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreChildNode.java (original)
+++ webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreChildNode.java Sat Jun 20 19:09:06 2015
@@ -19,5 +19,11 @@
 package org.apache.axiom.core;
 
 public interface CoreChildNode extends CoreNode {
-    
+    /**
+     * Get the parent element of this node.
+     * 
+     * @return the parent element of this node or <code>null</code> if the node has no parent or if
+     *         the parent is not an element
+     */
+    CoreElement coreGetParentElement();
 }

Modified: webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreChildNodeSupport.aj
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreChildNodeSupport.aj?rev=1686664&r1=1686663&r2=1686664&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreChildNodeSupport.aj (original)
+++ webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreChildNodeSupport.aj Sat Jun 20 19:09:06 2015
@@ -45,6 +45,10 @@ public aspect CoreChildNodeSupport {
         return getFlag(Flags.HAS_PARENT) ? owner : null;
     }
     
+    public final CoreElement CoreChildNode.coreGetParentElement() {
+        return owner instanceof CoreElement ? (CoreElement)owner : null;
+    }
+    
     public void CoreChildNode.internalSetParent(CoreParentNode parent) {
         if (parent == null) {
             throw new IllegalArgumentException();

Modified: webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreElement.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreElement.java?rev=1686664&r1=1686663&r2=1686664&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreElement.java (original)
+++ webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreElement.java Sat Jun 20 19:09:06 2015
@@ -18,6 +18,185 @@
  */
 package org.apache.axiom.core;
 
-public interface CoreElement extends CoreChildNode, CoreParentNode {
+import java.util.Iterator;
 
+public interface CoreElement extends CoreChildNode, CoreParentNode, DeferringParentNode {
+    /**
+     * Specifies the value that should be returned by
+     * {@link CoreElement#coreSetAttribute(AttributeMatcher, String, String, CoreAttribute, NodeMigrationPolicy, ReturnValue)}.
+     */
+    public enum ReturnValue {
+        /**
+         * Nothing should be returned.
+         */
+        NONE,
+        
+        /**
+         * The method will return the attribute that was effectively added to the element (which may
+         * be a clone of the attribute requested to be added if
+         * {@link NodeMigrationPolicy.Action#CLONE} is used).
+         */
+        ADDED_ATTRIBUTE,
+        
+        /**
+         * The method will return the attribute that was replaced by the new attribute, or
+         * <code>null</code> if no matching attribute existed.
+         */
+        REPLACED_ATTRIBUTE,
+    }
+    
+    /**
+     * Get the first attribute of this element.
+     * 
+     * @return the first attribute, or <code>null</code> if this element has no attributes
+     */
+    CoreAttribute coreGetFirstAttribute();
+
+    /**
+     * Get the last attribute of this element.
+     * 
+     * @return the last attribute, or <code>null</code> if this element has no attributes
+     */
+    CoreAttribute coreGetLastAttribute();
+    
+    /**
+     * Get the first attribute selected by a given {@link AttributeMatcher}.
+     * 
+     * @param matcher
+     *            the {@link AttributeMatcher} implementation to use
+     * @param namespaceURI
+     *            the <code>namespaceURI</code> parameter to pass to
+     *            {@link AttributeMatcher#matches(CoreAttribute, String, String)}
+     * @param name
+     *            the <code>name</code> parameter to pass to
+     *            {@link AttributeMatcher#matches(CoreAttribute, String, String)}
+     * @return the (first) matching attribute, or <code>null</code> if no matching attribute was
+     *         found
+     */
+    CoreAttribute coreGetAttribute(AttributeMatcher matcher, String namespaceURI, String name);
+    
+    /**
+     * Create or update an attribute based on a given {@link AttributeMatcher}.
+     * 
+     * @param matcher
+     *            the {@link AttributeMatcher} implementation to use
+     * @param namespaceURI
+     *            the <code>namespaceURI</code> parameter to pass to
+     *            {@link AttributeMatcher#matches(CoreAttribute, String, String)} and
+     *            {@link AttributeMatcher#createAttribute(NodeFactory, CoreDocument, String, String, String, String)}
+     * @param name
+     *            the <code>name</code> parameter to pass to
+     *            {@link AttributeMatcher#matches(CoreAttribute, String, String)} and
+     *            {@link AttributeMatcher#createAttribute(NodeFactory, CoreDocument, String, String, String, String)}
+     * @param prefix
+     *            the <code>prefix</code> parameter to pass to
+     *            {@link AttributeMatcher#createAttribute(NodeFactory, CoreDocument, String, String, String, String)}
+     *            and {@link AttributeMatcher#update(CoreAttribute, String, String)}
+     * @param value
+     *            the <code>value</code> parameter to pass to
+     *            {@link AttributeMatcher#createAttribute(NodeFactory, CoreDocument, String, String, String, String)}
+     *            and {@link AttributeMatcher#update(CoreAttribute, String, String)}
+     */
+    void coreSetAttribute(AttributeMatcher matcher, String namespaceURI, String name, String prefix, String value);
+    
+    /**
+     * Add a new attribute or replace an existing attribute based on a given
+     * {@link AttributeMatcher}. If a matching attribute on this element is found, it is replaced by
+     * the specified attribute. If no matching attribute is found, then the specified attribute is
+     * added to this element. If the attribute is already owned by this element, then calling this method
+     * has no effect.
+     * 
+     * @param matcher
+     *            the {@link AttributeMatcher} implementation to use
+     * @param attr
+     *            the new attribute to add
+     * @param policy
+     *            the policy to apply if the attribute already has an owner element or belongs to a
+     *            different document
+     * @param changeDocumentOfReplacedAttribute
+     *            specifies if the owner document of the replaced attribute (if any) should be
+     *            changed
+     * @param newDocument
+     *            the new owner document for the replaced attribute, or <code>null</code> if the
+     *            attribute will have its own owner document (which may be created lazily at a later
+     *            moment); only meaningful if <code>changeDocumentOfReplacedAttribute</code> is
+     *            <code>true</code
+     * @param returnValue
+     *            specifies the expected return value of the method
+     * @return the attribute as specified by the <code>returnValue</code> parameter
+     * @throws NodeMigrationException 
+     */
+    CoreAttribute coreSetAttribute(AttributeMatcher matcher, CoreAttribute attr, NodeMigrationPolicy policy, boolean changeDocumentOfReplacedAttribute, CoreDocument newDocument, ReturnValue returnValue) throws NodeMigrationException;
+
+    /**
+     * Append an attribute to this element. The attribute is simply added at the end of the list of
+     * attributes for this element. This method should be used with care because no provisions are
+     * made to ensure uniqueness of attribute names.
+     * 
+     * @param attr
+     *            the attribute to append
+     * @param policy
+     *            the policy to apply if the attribute already has an owner element or belongs to a
+     *            different document
+     * @throws NodeMigrationException
+     *             if appending the attribute was rejected by the policy
+     */
+    void coreAppendAttribute(CoreAttribute attr, NodeMigrationPolicy policy) throws NodeMigrationException;
+    
+    /**
+     * Remove an attribute based on a given {@link AttributeMatcher}.
+     * 
+     * @param matcher
+     *            the {@link AttributeMatcher} implementation to use
+     * @param namespaceURI
+     *            the <code>namespaceURI</code> parameter to pass to
+     *            {@link AttributeMatcher#matches(CoreAttribute, String, String)}
+     * @param name
+     *            the <code>name</code> parameter to pass to
+     *            {@link AttributeMatcher#matches(CoreAttribute, String, String)}
+     * @return <code>true</code> if a matching attribute was found (and has been removed),
+     *         <code>false</code> if no matching attribute was found
+     */
+    boolean coreRemoveAttribute(AttributeMatcher matcher, String namespaceURI, String name);
+    
+    <T extends CoreAttribute,S> Iterator<S> coreGetAttributesByType(Class<T> type, Mapper<T,S> mapper);
+    
+    /**
+     * Look up the namespace URI associated to the given prefix.
+     * 
+     * @param prefix
+     *            The prefix to look for. If this parameter is the empty string, then the URI of the
+     *            default namespace will be returned.
+     * @param strict
+     *            If this parameter is set to <code>true</code>, only namespace declarations will be
+     *            taken into account. If set to <code>false</code> the prefixes of the element and
+     *            its ancestors are also taken into account (limited to instanced of
+     *            {@link CoreNSAwareElement}), even if no explicit namespace declarations exists for
+     *            these prefixes.
+     * @return the namespace URI or <code>null</code> if the prefix is not bound; if the prefix is
+     *         the empty string and no default namespace declaration exists, then an empty string is
+     *         returned
+     */
+    String coreLookupNamespaceURI(String prefix, boolean strict);
+    
+    /**
+     * Find a prefix associated to the given namespace URI. Default namespaces are not taken into
+     * account by this method.
+     * 
+     * @param namespaceURI
+     *            The namespace URI to look for. This parameter must not be <code>null</code> (XML
+     *            forbids to bind a prefix to the null namespace).
+     * @param strict
+     *            If this parameter is set to <code>true</code>, only namespace declarations will be
+     *            taken into account. If set to <code>false</code> the prefixes of the element and
+     *            its ancestors are also taken into account (limited to instanced of
+     *            {@link CoreNSAwareElement}), even if no explicit namespace declarations exists for
+     *            these prefixes.
+     * @return a prefix bound to the given namespace URI or <code>null</code> if none is found
+     * @throws IllegalArgumentException
+     *             if <code>namespaceURI</code> is <code>null</code>
+     */
+    // TODO: wrong Javadoc: null vs. empty string
+    // TODO: we can support default namespaces!
+    String coreLookupPrefix(String namespaceURI, boolean strict);
 }

Modified: webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/NodeFactory.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/NodeFactory.java?rev=1686664&r1=1686663&r2=1686664&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/NodeFactory.java (original)
+++ webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/NodeFactory.java Sat Jun 20 19:09:06 2015
@@ -22,4 +22,7 @@ public interface NodeFactory {
     CoreDocument createDocument();
     CoreCharacterData createCharacterData();
     CoreCDATASection createCDATASection();
+    CoreNSUnawareAttribute createAttribute(CoreDocument document, String name, String value, String type);
+    CoreNSAwareAttribute createAttribute(CoreDocument document, String namespaceURI, String localName, String prefix, String value, String type);
+    CoreNamespaceDeclaration createNamespaceDeclaration(CoreDocument document, String prefix, String namespaceURI);
 }

Modified: webservices/axiom/trunk/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/DOMDocumentSupport.aj
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/DOMDocumentSupport.aj?rev=1686664&r1=1686663&r2=1686664&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/DOMDocumentSupport.aj (original)
+++ webservices/axiom/trunk/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/DOMDocumentSupport.aj Sat Jun 20 19:09:06 2015
@@ -18,6 +18,9 @@
  */
 package org.apache.axiom.dom;
 
+import javax.xml.XMLConstants;
+
+import org.w3c.dom.Attr;
 import org.w3c.dom.CDATASection;
 import org.w3c.dom.DOMConfiguration;
 import org.w3c.dom.DOMException;
@@ -106,4 +109,29 @@ public aspect DOMDocumentSupport {
         cdataSection.coreSetData(data);
         return cdataSection;
     }
+    
+    public final Attr DOMDocument.createAttribute(String name) {
+        NSUtil.validateName(name);
+        return (DOMAttribute)coreGetNodeFactory().createAttribute(this, name, "", "CDATA");
+    }
+
+    public final Attr DOMDocument.createAttributeNS(String namespaceURI, String qualifiedName) {
+        int i = NSUtil.validateQualifiedName(qualifiedName);
+        String prefix;
+        String localName;
+        if (i == -1) {
+            prefix = "";
+            localName = qualifiedName;
+        } else {
+            prefix = qualifiedName.substring(0, i);
+            localName = qualifiedName.substring(i+1);
+        }
+        if (XMLConstants.XMLNS_ATTRIBUTE_NS_URI.equals(namespaceURI)) {
+            return (DOMAttribute)coreGetNodeFactory().createNamespaceDeclaration(this, NSUtil.getDeclaredPrefix(localName, prefix), null);
+        } else {
+            namespaceURI = NSUtil.normalizeNamespaceURI(namespaceURI);
+            NSUtil.validateAttributeName(namespaceURI, localName, prefix);
+            return (DOMAttribute)coreGetNodeFactory().createAttribute(this, namespaceURI, localName, prefix, null, null);
+        }
+    }
 }

Modified: webservices/axiom/trunk/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/DOMElementSupport.aj
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/DOMElementSupport.aj?rev=1686664&r1=1686663&r2=1686664&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/DOMElementSupport.aj (original)
+++ webservices/axiom/trunk/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/DOMElementSupport.aj Sat Jun 20 19:09:06 2015
@@ -20,8 +20,12 @@ package org.apache.axiom.dom;
 
 import javax.xml.XMLConstants;
 
+import org.apache.axiom.core.AttributeMatcher;
+import org.apache.axiom.core.CoreModelException;
+import org.apache.axiom.core.CoreNSAwareAttribute;
+import org.apache.axiom.core.CoreNamespaceDeclaration;
 import org.w3c.dom.Attr;
-import org.w3c.dom.Element;
+import org.w3c.dom.DOMException;
 import org.w3c.dom.NamedNodeMap;
 import org.w3c.dom.Node;
 import org.w3c.dom.TypeInfo;
@@ -48,74 +52,45 @@ public aspect DOMElementSupport {
         throw new UnsupportedOperationException();
     }
 
-    public final String DOMElement.lookupNamespaceURI(String specifiedPrefix) {
-        String namespace = this.getNamespaceURI();
-        String prefix = this.getPrefix();
-        // First check for namespaces implicitly defined by the namespace prefix/URI of the element
-        if (prefix == null && specifiedPrefix == null
-                || prefix != null && prefix.equals(specifiedPrefix)) {
-            return namespace;
-        }
-        // looking in attributes
-        if (this.hasAttributes()) {
-            NamedNodeMap map = this.getAttributes();
-            int length = map.getLength();
-            for (int i = 0; i < length; i++) {
-                Node attr = map.item(i);
-                namespace = attr.getNamespaceURI();
-                if (namespace != null && namespace.equals(XMLConstants.XMLNS_ATTRIBUTE_NS_URI)) {
-                    // At this point we know that either the prefix of the attribute is null and
-                    // the local name is "xmlns" or the prefix is "xmlns" and the local name is the
-                    // namespace prefix declared by the namespace declaration. We check that constraint
-                    // when the attribute is created.
-                    String attrPrefix = attr.getPrefix();
-                    if ((specifiedPrefix == null && attrPrefix == null)
-                            || (specifiedPrefix != null && attrPrefix != null
-                                    && attr.getLocalName().equals(specifiedPrefix))) {
-                        String value = attr.getNodeValue();
-                        return value.length() > 0 ? value : null;
-                    }
-                }
-            }
+    public final String DOMElement.lookupNamespaceURI(String prefix) {
+        if (prefix == null) {
+            prefix = "";
+        } else if (prefix.length() == 0) {
+            return null;
         }
-        // looking in ancestor
-        DOMParentNode parent = (DOMParentNode)coreGetParent();
-        return parent instanceof Element ? parent.lookupNamespaceURI(specifiedPrefix) : null;
+        String namespaceURI = coreLookupNamespaceURI(prefix, false);
+        return namespaceURI == null || namespaceURI.length() == 0 ? null : namespaceURI;
     }
 
     public final String DOMElement.lookupPrefix(String namespaceURI) {
-        return lookupPrefix(namespaceURI, this);
-    }
-    
-    private final String DOMElement.lookupPrefix(String namespaceURI, Element originalElement) {
-        if (namespaceURI == null || namespaceURI.length() == 0) {
+        if (namespaceURI == null) {
             return null;
+        } else {
+            String prefix = coreLookupPrefix(namespaceURI, false);
+            return prefix == null || prefix.length() == 0 ? null : prefix;
         }
-        if (namespaceURI.equals(getNamespaceURI())) {
-            String prefix = getPrefix();
-            if (namespaceURI.equals(originalElement.lookupNamespaceURI(prefix))) {
-                return prefix;
-            }
-        }
-        if (this.hasAttributes()) {
-            NamedNodeMap map = this.getAttributes();
-            int length = map.getLength();
-            for (int i = 0; i < length; i++) {
-                Node attr = map.item(i);
-                String attrPrefix = attr.getPrefix();
-                if (attrPrefix != null && attrPrefix.equals(XMLConstants.XMLNS_ATTRIBUTE)
-                        && attr.getNodeValue().equals(namespaceURI)) {
-                    String prefix = attr.getLocalName();
-                    if (namespaceURI.equals(originalElement.lookupNamespaceURI(prefix))) {
-                        return prefix;
-                    }
-                }
-            }
-        }
-        DOMParentNode parent = (DOMParentNode)coreGetParent();
-        return parent instanceof Element ? ((DOMElement)parent).lookupPrefix(namespaceURI, originalElement) : null;
     }
 
+    public final boolean DOMElement.hasAttributes() {
+        return coreGetFirstAttribute() != null;
+    }
+
+    public final NamedNodeMap DOMElement.getAttributes() {
+        return new AttributesNamedNodeMap(this);
+    }
+    
+    public final Attr DOMElement.getAttributeNode(String name) {
+        return (DOMAttribute)coreGetAttribute(Policies.DOM1_ATTRIBUTE_MATCHER, null, name);
+    }
+
+    public final Attr DOMElement.getAttributeNodeNS(String namespaceURI, String localName) {
+        if (XMLConstants.XMLNS_ATTRIBUTE_NS_URI.equals(namespaceURI)) {
+            return (DOMAttribute)coreGetAttribute(AttributeMatcher.NAMESPACE_DECLARATION, null, localName.equals(XMLConstants.XMLNS_ATTRIBUTE) ? "" : localName);
+        } else {
+            return (DOMAttribute)coreGetAttribute(Policies.DOM2_ATTRIBUTE_MATCHER, namespaceURI == null ? "" : namespaceURI, localName);
+        }
+    }
+    
     public final String DOMElement.getAttribute(String name) {
         Attr attr = getAttributeNode(name);
         return attr != null ? attr.getValue() : "";
@@ -133,4 +108,81 @@ public aspect DOMElementSupport {
     public final boolean DOMElement.hasAttributeNS(String namespaceURI, String localName) {
         return getAttributeNodeNS(namespaceURI, localName) != null;
     }
+
+    public final void DOMElement.setAttribute(String name, String value) {
+        NSUtil.validateName(name);
+        coreSetAttribute(Policies.DOM1_ATTRIBUTE_MATCHER, null, name, null, value);
+    }
+
+    public final void DOMElement.setAttributeNS(String namespaceURI, String qualifiedName, String value) throws DOMException {
+        int i = NSUtil.validateQualifiedName(qualifiedName);
+        String prefix;
+        String localName;
+        if (i == -1) {
+            prefix = "";
+            localName = qualifiedName;
+        } else {
+            prefix = qualifiedName.substring(0, i);
+            localName = qualifiedName.substring(i+1);
+        }
+        if (XMLConstants.XMLNS_ATTRIBUTE_NS_URI.equals(namespaceURI)) {
+            coreSetAttribute(AttributeMatcher.NAMESPACE_DECLARATION, null, NSUtil.getDeclaredPrefix(localName, prefix), null, value);
+        } else {
+            namespaceURI = NSUtil.normalizeNamespaceURI(namespaceURI);
+            NSUtil.validateAttributeName(namespaceURI, localName, prefix);
+            coreSetAttribute(Policies.DOM2_ATTRIBUTE_MATCHER, namespaceURI, localName, prefix, value);
+        }
+    }
+
+    public final Attr DOMElement.setAttributeNode(Attr newAttr) throws DOMException {
+        return setAttributeNodeNS(newAttr);
+    }
+    
+    public final Attr DOMElement.setAttributeNodeNS(Attr _newAttr) throws DOMException {
+        DOMAttribute newAttr = (DOMAttribute)_newAttr;
+        if (newAttr.coreGetOwnerElement() == this) {
+            // This means that the "new" attribute is already linked to the element
+            // and replaces itself.
+            return newAttr;
+        } else {
+            AttributeMatcher matcher;
+            if (newAttr instanceof CoreNSAwareAttribute) {
+                matcher = Policies.DOM2_ATTRIBUTE_MATCHER;
+            } else if (newAttr instanceof CoreNamespaceDeclaration) {
+                matcher = AttributeMatcher.NAMESPACE_DECLARATION;
+            } else {
+                // Must be a DOM1 (namespace unaware) attribute
+                matcher = Policies.DOM1_ATTRIBUTE_MATCHER;
+            }
+            try {
+                return (DOMAttribute)coreSetAttribute(matcher, newAttr, Policies.ATTRIBUTE_MIGRATION_POLICY, false, null, ReturnValue.REPLACED_ATTRIBUTE);
+            } catch (CoreModelException ex) {
+                throw DOMExceptionUtil.translate(ex);
+            }
+        }
+    }
+
+    public final Attr DOMElement.removeAttributeNode(Attr oldAttr) throws DOMException {
+        DOMAttribute attr = (DOMAttribute)oldAttr;
+        if (attr.coreGetOwnerElement() != this) {
+            throw DOMExceptionUtil.newDOMException(DOMException.NOT_FOUND_ERR);
+        } else {
+            attr.coreRemove();
+        }
+        return attr;
+    }
+
+    public final void DOMElement.removeAttribute(String name) throws DOMException {
+        // Specs: "If no attribute with this name is found, this method has no effect."
+        coreRemoveAttribute(Policies.DOM1_ATTRIBUTE_MATCHER, null, name);
+    }
+
+    public final void DOMElement.removeAttributeNS(String namespaceURI, String localName) throws DOMException {
+        // Specs: "If no attribute with this local name and namespace URI is found, this method has no effect."
+        if (XMLConstants.XMLNS_ATTRIBUTE_NS_URI.equals(namespaceURI)) {
+            coreRemoveAttribute(AttributeMatcher.NAMESPACE_DECLARATION, null, localName.equals(XMLConstants.XMLNS_ATTRIBUTE) ? "" : localName);
+        } else {
+            coreRemoveAttribute(Policies.DOM2_ATTRIBUTE_MATCHER, namespaceURI == null ? "" : namespaceURI, localName);
+        }
+    }
 }

Modified: webservices/axiom/trunk/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/DOMExceptionUtil.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/DOMExceptionUtil.java?rev=1686664&r1=1686663&r2=1686664&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/DOMExceptionUtil.java (original)
+++ webservices/axiom/trunk/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/DOMExceptionUtil.java Sat Jun 20 19:09:06 2015
@@ -22,6 +22,9 @@ import java.util.MissingResourceExceptio
 import java.util.PropertyResourceBundle;
 import java.util.ResourceBundle;
 
+import org.apache.axiom.core.CoreModelException;
+import org.apache.axiom.core.NodeInUseException;
+import org.apache.axiom.core.WrongDocumentException;
 import org.w3c.dom.DOMException;
 
 public final class DOMExceptionUtil {
@@ -65,4 +68,14 @@ public final class DOMExceptionUtil {
             return new DOMException(code, key + ": " + message);
         }
     }
+
+    public static RuntimeException translate(CoreModelException ex) {
+        if (ex instanceof WrongDocumentException) {
+            return newDOMException(DOMException.WRONG_DOCUMENT_ERR);
+        } else if (ex instanceof NodeInUseException) {
+            return newDOMException(DOMException.INUSE_ATTRIBUTE_ERR);
+        } else {
+            throw new IllegalArgumentException("Don't know how to translate " + ex.getClass().getName());
+        }
+    }
 }

Modified: webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/AxiomAttribute.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/AxiomAttribute.java?rev=1686664&r1=1686663&r2=1686664&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/AxiomAttribute.java (original)
+++ webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/AxiomAttribute.java Sat Jun 20 19:09:06 2015
@@ -18,9 +18,9 @@
  */
 package org.apache.axiom.om.impl.common;
 
-import org.apache.axiom.core.CoreAttribute;
+import org.apache.axiom.core.CoreNSAwareAttribute;
 import org.apache.axiom.om.OMAttribute;
 
-public interface AxiomAttribute extends OMAttribute, CoreAttribute, AxiomNamedInformationItem {
+public interface AxiomAttribute extends OMAttribute, CoreNSAwareAttribute, AxiomNamedInformationItem {
 
 }

Modified: webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/AxiomAttributeSupport.aj
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/AxiomAttributeSupport.aj?rev=1686664&r1=1686663&r2=1686664&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/AxiomAttributeSupport.aj (original)
+++ webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/AxiomAttributeSupport.aj Sat Jun 20 19:09:06 2015
@@ -33,4 +33,20 @@ public aspect AxiomAttributeSupport {
     public final void AxiomAttribute.setOMNamespace(OMNamespace omNamespace) {
         internalSetNamespace(omNamespace);
     }
+    
+    public final String AxiomAttribute.getAttributeValue() {
+        return coreGetValue();
+    }
+    
+    public final void AxiomAttribute.setAttributeValue(String value) {
+        coreSetValue(value);
+    }
+    
+    public final String AxiomAttribute.getAttributeType() {
+        return coreGetType();
+    }
+
+    public final void AxiomAttribute.setAttributeType(String type) {
+        coreSetType(type);
+    }
 }

Modified: webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/AxiomElement.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/AxiomElement.java?rev=1686664&r1=1686663&r2=1686664&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/AxiomElement.java (original)
+++ webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/AxiomElement.java Sat Jun 20 19:09:06 2015
@@ -18,11 +18,11 @@
  */
 package org.apache.axiom.om.impl.common;
 
-import org.apache.axiom.core.CoreElement;
+import org.apache.axiom.core.CoreNSAwareElement;
 import org.apache.axiom.core.DeferringParentNode;
 import org.apache.axiom.om.OMNamespace;
 import org.apache.axiom.om.impl.OMElementEx;
 
-public interface AxiomElement extends OMElementEx, AxiomContainer, AxiomChildNode, AxiomNamedInformationItem, CoreElement, DeferringParentNode {
+public interface AxiomElement extends OMElementEx, AxiomContainer, AxiomChildNode, AxiomNamedInformationItem, CoreNSAwareElement, DeferringParentNode {
     void addNamespaceDeclaration(OMNamespace ns);
 }

Modified: webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/AxiomElementSupport.aj
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/AxiomElementSupport.aj?rev=1686664&r1=1686663&r2=1686664&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/AxiomElementSupport.aj (original)
+++ webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/AxiomElementSupport.aj Sat Jun 20 19:09:06 2015
@@ -31,7 +31,14 @@ import javax.xml.namespace.QName;
 import javax.xml.stream.XMLStreamException;
 import javax.xml.stream.XMLStreamReader;
 
+import org.apache.axiom.core.AttributeMatcher;
+import org.apache.axiom.core.CoreAttribute;
 import org.apache.axiom.core.CoreParentNode;
+import org.apache.axiom.core.IdentityMapper;
+import org.apache.axiom.core.NodeMigrationException;
+import org.apache.axiom.core.NodeMigrationPolicy;
+import org.apache.axiom.om.OMAttribute;
+import org.apache.axiom.om.OMConstants;
 import org.apache.axiom.om.OMContainer;
 import org.apache.axiom.om.OMElement;
 import org.apache.axiom.om.OMException;
@@ -40,8 +47,12 @@ import org.apache.axiom.om.OMNode;
 import org.apache.axiom.om.OMSourcedElement;
 import org.apache.axiom.om.OMText;
 import org.apache.axiom.om.impl.builder.StAXOMBuilder;
+import org.apache.axiom.om.impl.common.factory.AxiomNodeFactory;
+import org.apache.axiom.om.impl.util.OMSerializerUtil;
 import org.apache.axiom.util.namespace.MapBasedNamespaceContext;
 import org.apache.axiom.util.stax.XMLStreamReaderUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 
 /**
  * Utility class with default implementations for some of the methods defined by the
@@ -50,6 +61,8 @@ import org.apache.axiom.util.stax.XMLStr
 public aspect AxiomElementSupport {
     declare parents: (InformationItem+ && OMElement+) implements AxiomElement;
     
+    private static final Log log = LogFactory.getLog(AxiomElementSupport.class);
+    
     public final int AxiomElement.getType() {
         return OMNode.ELEMENT_NODE;
     }
@@ -285,4 +298,233 @@ public aspect AxiomElementSupport {
             return namespace;
         }
     }
+    
+    public final void AxiomElement.internalAppendAttribute(OMAttribute attr) {
+        try {
+            coreSetAttribute(Policies.ATTRIBUTE_MATCHER, (AxiomAttribute)attr, NodeMigrationPolicy.MOVE_ALWAYS, true, null, ReturnValue.NONE);
+        } catch (NodeMigrationException ex) {
+            AxiomExceptionUtil.translate(ex);
+        }
+    }
+    
+    public final OMAttribute AxiomElement.addAttribute(OMAttribute attr){
+        // If the attribute already has an owner element then clone the attribute (except if it is owned
+        // by the this element)
+        OMElement owner = attr.getOwner();
+        if (owner != null) {
+            if (owner == this) {
+                return attr;
+            }
+            attr = getOMFactory().createOMAttribute(attr.getLocalName(), attr.getNamespace(), attr.getAttributeValue());
+        }
+
+        OMNamespace namespace = attr.getNamespace();
+        if (namespace != null) {
+            String uri = namespace.getNamespaceURI();
+            if (uri.length() > 0) {
+                String prefix = namespace.getPrefix();
+                OMNamespace ns2 = findNamespaceURI(prefix);
+                if (ns2 == null || !uri.equals(ns2.getNamespaceURI())) {
+                    declareNamespace(uri, prefix);
+                }
+            }
+        }
+
+        internalAppendAttribute(attr);
+        return attr;
+    }
+
+    public final OMAttribute AxiomElement.addAttribute(String localName, String value, OMNamespace ns) {
+        OMNamespace namespace = null;
+        if (ns != null) {
+            String namespaceURI = ns.getNamespaceURI();
+            String prefix = ns.getPrefix();
+            if (namespaceURI.length() > 0 || prefix != null) {
+                namespace = findNamespace(namespaceURI, prefix);
+                if (namespace == null || prefix == null && namespace.getPrefix().length() == 0) {
+                    namespace = new OMNamespaceImpl(namespaceURI, prefix != null ? prefix : OMSerializerUtil.getNextNSPrefix());
+                }
+            }
+        }
+        return addAttribute(getOMFactory().createOMAttribute(localName, namespace, value));
+    }
+
+    private static final IdentityMapper<AxiomAttribute> attributeIdentityMapper = new IdentityMapper<AxiomAttribute>();
+    
+    @SuppressWarnings("rawtypes")
+    public final Iterator AxiomElement.getAllAttributes() {
+        return coreGetAttributesByType(AxiomAttribute.class, attributeIdentityMapper);
+    }
+    
+    public final OMAttribute AxiomElement.getAttribute(QName qname) {
+        return (AxiomAttribute)coreGetAttribute(Policies.ATTRIBUTE_MATCHER, qname.getNamespaceURI(), qname.getLocalPart());
+    }
+
+    public final String AxiomElement.getAttributeValue(QName qname) {
+        OMAttribute attr = getAttribute(qname);
+        return attr == null ? null : attr.getAttributeValue();
+    }
+
+    public final void AxiomElement.removeAttribute(OMAttribute attr) {
+        if (attr.getOwner() != this) {
+            throw new OMException("The attribute is not owned by this element");
+        }
+        ((AxiomAttribute)attr).coreRemove(null);
+    }
+
+    public final OMNamespace AxiomElement.addNamespaceDeclaration(String uri, String prefix) {
+        OMNamespace ns = new OMNamespaceImpl(uri, prefix);
+        try {
+            coreAppendAttribute(((AxiomNodeFactory)getOMFactory()).createNamespaceDeclaration(ns), NodeMigrationPolicy.MOVE_ALWAYS);
+        } catch (NodeMigrationException ex) {
+            throw AxiomExceptionUtil.translate(ex);
+        }
+        return ns;
+    }
+    
+    public final void AxiomElement.addNamespaceDeclaration(OMNamespace ns) {
+        try {
+            coreSetAttribute(AttributeMatcher.NAMESPACE_DECLARATION,
+                    ((AxiomNodeFactory)getOMFactory()).createNamespaceDeclaration(ns),
+                    NodeMigrationPolicy.MOVE_ALWAYS, true, null, ReturnValue.NONE);
+        } catch (NodeMigrationException ex) {
+            throw AxiomExceptionUtil.translate(ex);
+        }
+    }
+    
+    @SuppressWarnings("rawtypes")
+    public final Iterator AxiomElement.getAllDeclaredNamespaces() {
+        return coreGetAttributesByType(AxiomNamespaceDeclaration.class, NamespaceDeclarationMapper.INSTANCE);
+    }
+
+    public final OMNamespace AxiomElement.declareNamespace(OMNamespace namespace) {
+        String prefix = namespace.getPrefix();
+        if (prefix == null) {
+            prefix = OMSerializerUtil.getNextNSPrefix();
+            namespace = new OMNamespaceImpl(namespace.getNamespaceURI(), prefix);
+        }
+        if (prefix.length() > 0 && namespace.getNamespaceURI().length() == 0) {
+            throw new IllegalArgumentException("Cannot bind a prefix to the empty namespace name");
+        }
+        addNamespaceDeclaration(namespace);
+        return namespace;
+    }
+
+    public final OMNamespace AxiomElement.declareNamespace(String uri, String prefix) {
+        if ("".equals(prefix)) {
+            log.warn("Deprecated usage of OMElement#declareNamespace(String,String) with empty prefix");
+            prefix = OMSerializerUtil.getNextNSPrefix();
+        }
+        OMNamespaceImpl ns = new OMNamespaceImpl(uri, prefix);
+        return declareNamespace(ns);
+    }
+
+    public final OMNamespace AxiomElement.declareDefaultNamespace(String uri) {
+        OMNamespace elementNamespace = getNamespace();
+        if (elementNamespace == null && uri.length() > 0
+                || elementNamespace != null && elementNamespace.getPrefix().length() == 0 && !elementNamespace.getNamespaceURI().equals(uri)) {
+            throw new OMException("Attempt to add a namespace declaration that conflicts with " +
+                    "the namespace information of the element");
+        }
+        OMNamespace namespace = new OMNamespaceImpl(uri == null ? "" : uri, "");
+        addNamespaceDeclaration(namespace);
+        return namespace;
+    }
+
+    public final void AxiomElement.undeclarePrefix(String prefix) {
+        addNamespaceDeclaration(new OMNamespaceImpl("", prefix));
+    }
+
+    public final OMNamespace AxiomElement.findNamespace(String uri, String prefix) {
+
+        // check in the current element
+        OMNamespace namespace = findDeclaredNamespace(uri, prefix);
+        if (namespace != null) {
+            return namespace;
+        }
+
+        // go up to check with ancestors
+        OMContainer parent = getParent();
+        if (parent != null) {
+            //For the OMDocumentImpl there won't be any explicit namespace
+            //declarations, so going up the parent chain till the document
+            //element should be enough.
+            if (parent instanceof OMElement) {
+                namespace = ((OMElement) parent).findNamespace(uri, prefix);
+                // If the prefix has been redeclared, then ignore the binding found on the ancestors
+                if (prefix == null && namespace != null && findDeclaredNamespace(null, namespace.getPrefix()) != null) {
+                    namespace = null;
+                }
+            }
+        }
+
+        return namespace;
+    }
+
+    private static final OMNamespace XMLNS = new OMNamespaceImpl(OMConstants.XMLNS_URI, OMConstants.XMLNS_PREFIX);
+
+    /**
+     * Checks for the namespace <B>only</B> in the current Element. This is also used to retrieve
+     * the prefix of a known namespace URI.
+     */
+    private OMNamespace AxiomElement.findDeclaredNamespace(String uri, String prefix) {
+        // Seems weird, but necessary for compatibility with older versions
+        if (uri != null && prefix != null && prefix.length() == 0) {
+            prefix = null;
+        }
+        
+        CoreAttribute attr = coreGetFirstAttribute();
+        while (attr != null) {
+            if (attr instanceof AxiomNamespaceDeclaration) {
+                OMNamespace namespace = ((AxiomNamespaceDeclaration)attr).getDeclaredNamespace();
+                if ((prefix == null || prefix.equals(namespace.getPrefix()))
+                        && (uri == null || uri.equals(namespace.getNamespaceURI()))) {
+                    return namespace;
+                }
+            }
+            attr = attr.coreGetNextAttribute();
+        }
+
+        //If the prefix is available and uri is available and its the xml namespace
+        if ((prefix == null || prefix.equals(OMConstants.XMLNS_PREFIX))
+                && (uri == null || uri.equals(OMConstants.XMLNS_URI))) {
+            return XMLNS;
+        } else {
+            return null;
+        }
+    }
+
+    public final OMNamespace AxiomElement.findNamespaceURI(String prefix) {
+        if (prefix == null) {
+            throw new IllegalArgumentException();
+        }
+        CoreAttribute attr = coreGetFirstAttribute();
+        while (attr != null) {
+            if (attr instanceof AxiomNamespaceDeclaration) {
+                AxiomNamespaceDeclaration nsDecl = (AxiomNamespaceDeclaration)attr;
+                if (nsDecl.coreGetDeclaredPrefix().equals(prefix)) {
+                    OMNamespace ns = nsDecl.getDeclaredNamespace();
+                    if (ns.getNamespaceURI().length() == 0) {
+                        // We are either in the prefix undeclaring case (XML 1.1 only) or the namespace
+                        // declaration is xmlns="". In both cases we need to return null.
+                        return null;
+                    } else {
+                        return ns;
+                    }
+                }
+            }
+            attr = attr.coreGetNextAttribute();
+        }
+        OMContainer parent = getParent();
+        if (parent instanceof OMElement) {
+            // try with the parent
+            return ((OMElement)parent).findNamespaceURI(prefix);
+        } else {
+            return null;
+        }
+    }
+
+    public final OMNamespace AxiomElement.getDefaultNamespace() {
+        return findNamespaceURI("");
+    }
 }

Modified: webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/AxiomNamedInformationItem.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/AxiomNamedInformationItem.java?rev=1686664&r1=1686663&r2=1686664&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/AxiomNamedInformationItem.java (original)
+++ webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/AxiomNamedInformationItem.java Sat Jun 20 19:09:06 2015
@@ -18,8 +18,9 @@
  */
 package org.apache.axiom.om.impl.common;
 
+import org.apache.axiom.core.CoreNSAwareNamedNode;
 import org.apache.axiom.om.OMNamedInformationItem;
 
-public interface AxiomNamedInformationItem extends OMNamedInformationItem, AxiomInformationItem {
+public interface AxiomNamedInformationItem extends OMNamedInformationItem, AxiomInformationItem, CoreNSAwareNamedNode {
 
 }

Modified: webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/AxiomNamedInformationItemSupport.aj
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/AxiomNamedInformationItemSupport.aj?rev=1686664&r1=1686663&r2=1686664&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/AxiomNamedInformationItemSupport.aj (original)
+++ webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/AxiomNamedInformationItemSupport.aj Sat Jun 20 19:09:06 2015
@@ -20,6 +20,7 @@ package org.apache.axiom.om.impl.common;
 
 import javax.xml.namespace.QName;
 
+import org.apache.axiom.om.OMException;
 import org.apache.axiom.om.OMNamespace;
 import org.apache.axiom.om.impl.util.OMSerializerUtil;
 
@@ -159,4 +160,31 @@ public aspect AxiomNamedInformationItemS
             return ns;
         }
     }
+    
+    public final String AxiomNamedInformationItem.coreGetNamespaceURI() {
+        OMNamespace namespace = getNamespace();
+        return namespace == null ? "" : namespace.getNamespaceURI();
+    }
+    
+    public final String AxiomNamedInformationItem.coreGetPrefix() {
+        OMNamespace namespace = getNamespace();
+        return namespace == null ? "" : namespace.getPrefix();
+    }
+
+    public final String AxiomNamedInformationItem.coreGetLocalName() {
+        return getLocalName();
+    }
+    
+    public final void AxiomNamedInformationItem.coreSetPrefix(String prefix) {
+        OMNamespace ns = getNamespace();
+        if (ns == null) {
+            if (prefix.length() > 0) {
+                throw new OMException("Cannot set prefix on an information item without namespace");
+            } else {
+                // No need to set a new OMNamespace in this case
+            }
+        } else {
+            internalSetNamespace(new OMNamespaceImpl(ns.getNamespaceURI(), prefix));
+        }
+    }
 }

Modified: webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/factory/AxiomNodeFactory.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/factory/AxiomNodeFactory.java?rev=1686664&r1=1686663&r2=1686664&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/factory/AxiomNodeFactory.java (original)
+++ webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/factory/AxiomNodeFactory.java Sat Jun 20 19:09:06 2015
@@ -19,8 +19,10 @@
 package org.apache.axiom.om.impl.common.factory;
 
 import org.apache.axiom.core.NodeFactory;
+import org.apache.axiom.om.OMNamespace;
 import org.apache.axiom.om.impl.builder.OMFactoryEx;
+import org.apache.axiom.om.impl.common.AxiomNamespaceDeclaration;
 
 public interface AxiomNodeFactory extends NodeFactory, OMFactoryEx {
-
+    AxiomNamespaceDeclaration createNamespaceDeclaration(OMNamespace namespace);
 }

Modified: webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/serializer/pull/Navigator.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/serializer/pull/Navigator.java?rev=1686664&r1=1686663&r2=1686664&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/serializer/pull/Navigator.java (original)
+++ webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/serializer/pull/Navigator.java Sat Jun 20 19:09:06 2015
@@ -302,6 +302,7 @@ final class Navigator extends PullSerial
     }
 
     private void loadAttributes() {
+        // TODO: use the core model API to do this without iterators
         if (attributeCount == -1) {
             attributeCount = 0;
             for (Iterator it = ((OMElement)node).getAllAttributes(); it.hasNext(); ) {
@@ -323,6 +324,7 @@ final class Navigator extends PullSerial
     }
     
     private void loadNamespaces() {
+        // TODO: use the core model API to do this without iterators
         if (namespaceCount == -1) {
             namespaceCount = 0;
             for (Iterator it = ((OMElement)node).getAllDeclaredNamespaces(); it.hasNext(); ) {

Modified: webservices/axiom/trunk/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/AttrImpl.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/AttrImpl.java?rev=1686664&r1=1686663&r2=1686664&view=diff
==============================================================================
--- webservices/axiom/trunk/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/AttrImpl.java (original)
+++ webservices/axiom/trunk/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/AttrImpl.java Sat Jun 20 19:09:06 2015
@@ -19,22 +19,9 @@
 
 package org.apache.axiom.om.impl.dom;
 
-import static org.apache.axiom.dom.DOMExceptionUtil.newDOMException;
-
-import javax.xml.XMLConstants;
-
 import org.apache.axiom.core.NonDeferringParentNode;
 import org.apache.axiom.dom.DOMAttribute;
-import org.apache.axiom.om.OMAttribute;
-import org.apache.axiom.om.OMCloneOptions;
-import org.apache.axiom.om.OMConstants;
 import org.apache.axiom.om.OMFactory;
-import org.apache.axiom.om.OMNamespace;
-import org.apache.axiom.om.impl.OMAttributeEx;
-import org.apache.axiom.om.impl.common.AxiomAttribute;
-import org.apache.axiom.om.impl.common.AxiomText;
-import org.apache.axiom.om.impl.common.OMNamespaceImpl;
-import org.w3c.dom.Attr;
 import org.w3c.dom.DOMException;
 import org.w3c.dom.Element;
 import org.w3c.dom.Node;
@@ -42,73 +29,15 @@ import org.w3c.dom.Text;
 import org.w3c.dom.TypeInfo;
 
 /** Implementation of <code>org.w3c.dom.Attr</code> and <code>org.apache.axiom.om.OMAttribute</code> */
-public class AttrImpl extends RootNode implements OMAttributeEx, AxiomAttribute, DOMAttribute, NamedNode, NonDeferringParentNode {
-    private String type;
-
+public abstract class AttrImpl extends RootNode implements DOMAttribute, NonDeferringParentNode {
     /** Flag used to mark an attribute as per the DOM Level 3 specification */
     protected boolean isId;
 
-    private AttrImpl(DocumentImpl ownerDocument, OMFactory factory) {
+    AttrImpl(DocumentImpl ownerDocument, OMFactory factory) {
         super(factory);
         coreSetOwnerDocument(ownerDocument);
     }
 
-    // TODO: copy isId?
-    private AttrImpl(String localName, OMNamespace namespace, String type, OMFactory factory) {
-        this(null, factory);
-        internalSetLocalName(localName);
-        internalSetNamespace(namespace);
-        this.type = type;
-    }
-    
-    public AttrImpl(DocumentImpl ownerDocument, String localName,
-                    OMNamespace ns, String value, OMFactory factory) {
-        this(ownerDocument, factory);
-        if (ns != null) {
-            if (ns.getNamespaceURI().length() == 0) {
-                if (ns.getPrefix().length() > 0) {
-                    throw new IllegalArgumentException("Cannot create a prefixed attribute with an empty namespace name");
-                } else {
-                    ns = null;
-                }
-            } else if (ns.getPrefix().length() == 0) {
-                throw new IllegalArgumentException("Cannot create an unprefixed attribute with a namespace");
-            }
-        }
-        internalSetLocalName(localName);
-        coreAppendChild((AxiomText)factory.createOMText(value), false);
-        this.type = OMConstants.XMLATTRTYPE_CDATA;
-        internalSetNamespace(ns);
-    }
-
-    public AttrImpl(DocumentImpl ownerDocument, String name, String value,
-                    OMFactory factory) {
-        this(ownerDocument, factory);
-        internalSetLocalName(name);
-        coreAppendChild((AxiomText)factory.createOMText(value), false);
-        this.type = OMConstants.XMLATTRTYPE_CDATA;
-    }
-
-    public AttrImpl(DocumentImpl ownerDocument, String name, OMFactory factory) {
-        this(ownerDocument, factory);
-        internalSetLocalName(name);
-        //If this is a default namespace attr
-        if (XMLConstants.XMLNS_ATTRIBUTE.equals(name)) {
-            // TODO: this looks wrong; if the attribute name is "xmlns", then the prefix shouldn't be "xmlns"
-            internalSetNamespace(new OMNamespaceImpl(
-                    XMLConstants.XMLNS_ATTRIBUTE_NS_URI, XMLConstants.XMLNS_ATTRIBUTE));
-        }
-        this.type = OMConstants.XMLATTRTYPE_CDATA;
-    }
-
-    public AttrImpl(DocumentImpl ownerDocument, String localName,
-                    OMNamespace namespace, OMFactory factory) {
-        this(ownerDocument, factory);
-        internalSetLocalName(localName);
-        internalSetNamespace(namespace);
-        this.type = OMConstants.XMLATTRTYPE_CDATA;
-    }
-
     // /
     // /org.w3c.dom.Node methods
     // /
@@ -156,23 +85,6 @@ public class AttrImpl extends RootNode i
     // /
     // /org.w3c.dom.Attr methods
     // /
-    public String getName() {
-        OMNamespace namespace = getNamespace();
-        String localName = getLocalName();
-        if (namespace != null) {
-            if ((XMLConstants.XMLNS_ATTRIBUTE.equals(localName))) {
-                return localName;
-            } else if (XMLConstants.XMLNS_ATTRIBUTE_NS_URI.equals(namespace.getNamespaceURI())) {
-                return XMLConstants.XMLNS_ATTRIBUTE + ":" + localName;
-            } else if (namespace.getPrefix().equals("")) {
-                return localName;
-            } else {
-                return namespace.getPrefix() + ":" + localName;
-            }
-        } else {
-            return localName;
-        }
-    }
 
     /**
      * Returns the owner element.
@@ -199,38 +111,6 @@ public class AttrImpl extends RootNode i
         coreSetSpecified(specified);
     }
 
-    public String getAttributeValue() {
-        return getValue();
-    }
-
-    public String getAttributeType() {
-        return type;
-    }
-
-    /**
-     * Sets the attribute value.
-     *
-     * @see org.apache.axiom.om.OMAttribute#setAttributeValue(String)
-     */
-    public void setAttributeValue(String value) {
-        setValue(value);
-    }
-
-    /**
-     * Sets the attribute value.
-     *
-     * @see org.apache.axiom.om.OMAttribute#setAttributeType(String)
-     */
-    public void setAttributeType(String attrType) {    
-    	this.type = attrType;
-    }
-
-    final void checkInUse() {
-        if (coreGetOwnerElement() != null) {
-            throw newDOMException(DOMException.INUSE_ATTRIBUTE_ERR);
-        }
-    }
-
     /**
      * Sets the value of the attribute.
      *
@@ -240,6 +120,14 @@ public class AttrImpl extends RootNode i
         setTextContent(value);
     }
 
+    public final String coreGetValue() {
+        return getValue();
+    }
+    
+    public final void coreSetValue(String value) {
+        setValue(value);
+    }
+
     /*
      * DOM-Level 3 methods
      */
@@ -252,19 +140,6 @@ public class AttrImpl extends RootNode i
         return isId;
     }
 
-    public String toString() {
-        OMNamespace namespace = getNamespace();
-        String localName = getLocalName();
-        return (namespace == null) ? localName : namespace
-                .getPrefix()
-                + ":" + localName;
-    }
-
-    ParentNode shallowClone(OMCloneOptions options, ParentNode targetParent, boolean namespaceRepairing) {
-        // Note: targetParent is always null here
-        return new AttrImpl(getLocalName(), getNamespace(), type, getOMFactory());
-    }
-
     public final boolean isComplete() {
         return true;
     }

Modified: webservices/axiom/trunk/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DocumentImpl.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DocumentImpl.java?rev=1686664&r1=1686663&r2=1686664&view=diff
==============================================================================
--- webservices/axiom/trunk/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DocumentImpl.java (original)
+++ webservices/axiom/trunk/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DocumentImpl.java Sat Jun 20 19:09:06 2015
@@ -22,12 +22,14 @@ package org.apache.axiom.om.impl.dom;
 import static org.apache.axiom.dom.DOMExceptionUtil.newDOMException;
 
 import org.apache.axiom.core.CoreChildNode;
+import org.apache.axiom.core.CoreModelException;
+import org.apache.axiom.core.NodeMigrationPolicy;
 import org.apache.axiom.dom.DOMDocument;
+import org.apache.axiom.dom.DOMExceptionUtil;
 import org.apache.axiom.om.OMCloneOptions;
 import org.apache.axiom.om.OMElement;
 import org.apache.axiom.om.OMException;
 import org.apache.axiom.om.OMFactory;
-import org.apache.axiom.om.OMNamespace;
 import org.apache.axiom.om.OMNode;
 import org.apache.axiom.om.OMOutputFormat;
 import org.apache.axiom.om.OMXMLParserWrapper;
@@ -50,10 +52,6 @@ import org.w3c.dom.NamedNodeMap;
 import org.w3c.dom.Node;
 import org.w3c.dom.ProcessingInstruction;
 
-import javax.xml.XMLConstants;
-import javax.xml.stream.XMLStreamException;
-
-import java.io.OutputStream;
 import java.util.Enumeration;
 import java.util.Hashtable;
 import java.util.Iterator;
@@ -93,28 +91,6 @@ public class DocumentImpl extends RootNo
     // /org.w3c.dom.Document methods
     // /
 
-    public Attr createAttribute(String name) throws DOMException {
-        if (!DOMUtil.isQualifiedName(name)) {
-            throw newDOMException(DOMException.INVALID_CHARACTER_ERR);
-        }
-        return new AttrImpl(this, name, getOMFactory());
-    }
-
-    public Attr createAttributeNS(String namespaceURI, String qualifiedName)
-            throws DOMException {
-        String localName = DOMUtil.getLocalName(qualifiedName);
-        String prefix = DOMUtil.getPrefix(qualifiedName);
-        DOMUtil.validateAttrName(namespaceURI, localName, prefix);
-
-        OMNamespace namespace;
-        if (namespaceURI == null) {
-            namespace = null;
-        } else {
-            namespace = new OMNamespaceImpl(namespaceURI, prefix == null ? "" : prefix);
-        }
-        return new AttrImpl(this, localName, namespace, getOMFactory());
-    }
-
     public Comment createComment(String data) {
         CommentImpl comment = new CommentImpl(data, getOMFactory());
         comment.coreSetOwnerDocument(this);
@@ -226,17 +202,11 @@ public class DocumentImpl extends RootNo
                 if (sourceAttrs != null) {
                     int length = sourceAttrs.getLength();
                     for (int index = 0; index < length; index++) {
-                        Attr attr = (Attr) sourceAttrs.item(index);
-                        if (attr.getNamespaceURI() != null
-                                && !attr.getNamespaceURI().equals(
-                                XMLConstants.XMLNS_ATTRIBUTE_NS_URI)) {
-                            Attr newAttr = (Attr) importNode(attr, true);
-                            newElement.setAttributeNodeNS(newAttr);
-                        } else { // if (attr.getLocalName() == null) {
-                            Attr newAttr = (Attr) importNode(attr, true);
-                            newElement.setAttributeNode(newAttr);
+                        try {
+                            ((ElementImpl)newElement).coreAppendAttribute((AttrImpl)importNode(sourceAttrs.item(index), true), NodeMigrationPolicy.MOVE_ALWAYS);
+                        } catch (CoreModelException ex) {
+                            throw DOMExceptionUtil.translate(ex);
                         }
-
                     }
                 }
                 newNode = newElement;
@@ -244,19 +214,13 @@ public class DocumentImpl extends RootNo
             }
 
             case Node.ATTRIBUTE_NODE: {
-                if ("".equals(importedNode.getNamespaceURI())
-                        || importedNode.getNamespaceURI() == null) {
+                if (importedNode.getLocalName() == null) {
                     newNode = createAttribute(importedNode.getNodeName());
                 } else {
-                    //Check whether it is a default ns decl
-                    if (XMLConstants.XMLNS_ATTRIBUTE.equals(importedNode.getNodeName())) {
-                        newNode = createAttribute(importedNode.getNodeName());
-                    } else {
-                        String ns = importedNode.getNamespaceURI();
-                        ns = (ns != null) ? ns.intern() : null;
-                        newNode = createAttributeNS(ns ,
-                                                    importedNode.getNodeName());
-                    }
+                    String ns = importedNode.getNamespaceURI();
+                    ns = (ns != null) ? ns.intern() : null;
+                    newNode = createAttributeNS(ns ,
+                                                importedNode.getNodeName());
                 }
                 ((Attr) newNode).setValue(importedNode.getNodeValue());
                 break;