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/13 10:48:16 UTC

svn commit: r1685220 [1/2] - in /webservices/axiom/branches/attrs-aspects: aspects/core-aspects/src/main/java/org/apache/axiom/core/ aspects/dom-aspects/src/main/java/org/apache/axiom/dom/ implementations/axiom-dom/src/main/java/org/apache/axiom/om/imp...

Author: veithen
Date: Sat Jun 13 08:48:15 2015
New Revision: 1685220

URL: http://svn.apache.org/r1685220
Log:
Create parts of the infrastructure required to unify attribute handling and start to rewrite the corresponding DOOM code.

Added:
    webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/AttributeMatcher.java   (with props)
    webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreElementSupport.aj   (with props)
    webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreModelException.java   (with props)
    webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreNSAwareAttribute.java   (with props)
    webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreNSAwareNamedNode.java   (with props)
    webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreNSUnawareAttribute.java   (with props)
    webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreNSUnawareNamedNode.java   (with props)
    webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreNamespaceDeclaration.java   (with props)
    webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreTypedAttribute.java   (with props)
    webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/NSAwareAttributeMatcher.java   (with props)
    webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/NodeInUseException.java   (with props)
    webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/NodeMigrationException.java   (with props)
    webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/NodeMigrationPolicy.java   (with props)
    webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/WrongDocumentException.java   (with props)
    webservices/axiom/branches/attrs-aspects/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/AttributesNamedNodeMap.java   (with props)
    webservices/axiom/branches/attrs-aspects/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/DOMNamespaceDeclaration.java   (with props)
    webservices/axiom/branches/attrs-aspects/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/DOMNamespaceDeclarationSupport.aj   (with props)
    webservices/axiom/branches/attrs-aspects/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/Policies.java   (with props)
    webservices/axiom/branches/attrs-aspects/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/NSAwareAttribute.java   (with props)
    webservices/axiom/branches/attrs-aspects/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/NamespaceDeclaration.java   (with props)
Modified:
    webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreAttribute.java
    webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreAttributeSupport.aj
    webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreElement.java
    webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/NodeFactory.java
    webservices/axiom/branches/attrs-aspects/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/DOMElementSupport.aj
    webservices/axiom/branches/attrs-aspects/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/DOMExceptionUtil.java
    webservices/axiom/branches/attrs-aspects/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/AttrImpl.java
    webservices/axiom/branches/attrs-aspects/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DocumentImpl.java
    webservices/axiom/branches/attrs-aspects/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ElementImpl.java
    webservices/axiom/branches/attrs-aspects/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/factory/OMDOMFactory.java
    webservices/axiom/branches/attrs-aspects/implementations/axiom-dom/src/main/java/org/apache/axiom/soap/impl/dom/SOAPHeaderBlockImpl.java
    webservices/axiom/branches/attrs-aspects/implementations/axiom-dom/src/main/java/org/apache/axiom/soap/impl/dom/soap12/SOAP12FaultTextImpl.java
    webservices/axiom/branches/attrs-aspects/implementations/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMAttributeImpl.java
    webservices/axiom/branches/attrs-aspects/implementations/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/factory/OMLinkedListImplFactory.java

Added: webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/AttributeMatcher.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/AttributeMatcher.java?rev=1685220&view=auto
==============================================================================
--- webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/AttributeMatcher.java (added)
+++ webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/AttributeMatcher.java Sat Jun 13 08:48:15 2015
@@ -0,0 +1,147 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.axiom.core;
+
+/**
+ * Selects, creates or updates an attribute based on some match rule.
+ */
+public interface AttributeMatcher {
+    /**
+     * {@link AttributeMatcher} that matches {@link CoreNamespaceDeclaration} attributes based on
+     * the declared prefix. Parameters are defined as follows:
+     * <dl>
+     * <dt><code>namespaceURI</code>
+     * <dd>Not used.
+     * <dt><code>name</code>
+     * <dd>The prefix declared by the namespace declaration, or the empty string for the default
+     * namespace declaration.
+     * <dt><code>value</code>
+     * <dd>The namespace URI of the namespace declaration.
+     * <dt><code>prefix</code>
+     * <dd>Not used.
+     * </dl>
+     * 
+     * @author Andreas Veithen
+     */
+    AttributeMatcher NAMESPACE_DECLARATION = new AttributeMatcher() {
+        public boolean matches(CoreAttribute attr, String namespaceURI, String name) {
+            if (attr instanceof CoreNamespaceDeclaration) {
+                String prefix = ((CoreNamespaceDeclaration)attr).coreGetDeclaredPrefix();
+                return name.equals(prefix);
+            } else {
+                return false;
+            }
+        }
+
+        public CoreAttribute createAttribute(NodeFactory nodeFactory, CoreDocument document, String namespaceURI, String name, String prefix, String value) {
+            return nodeFactory.createNamespaceDeclaration(document, name, value);
+        }
+
+        public String getNamespaceURI(CoreAttribute attr) {
+            return null;
+        }
+
+        public String getName(CoreAttribute attr) {
+            return ((CoreNamespaceDeclaration)attr).coreGetDeclaredPrefix();
+        }
+
+        public void update(CoreAttribute attr, String prefix, String value) {
+            attr.coreSetValue(value);
+        }
+    };
+    
+    /**
+     * Check if the given attribute matches. The values of the <code>namespaceURI</code> and
+     * <code>name</code> parameters are those passed to
+     * {@link CoreElement#coreGetAttribute(AttributeMatcher, String, String)} or
+     * {@link CoreElement#coreSetAttribute(AttributeMatcher, String, String, String, String)}, or
+     * they are determined by the return values of {@link #getNamespaceURI(CoreAttribute)} and
+     * {@link #getName(CoreAttribute)} if
+     * {@link CoreElement#coreSetAttribute(AttributeMatcher, CoreAttribute, NodeMigrationPolicy, boolean, CoreDocument, com.googlecode.ddom.core.CoreElement.ReturnValue)}
+     * is used. It is
+     * not required that these parameters strictly represent the namespace URI and local name of the
+     * attribute. Their exact meaning is defined by the particular {@link AttributeMatcher}
+     * implementation.
+     * 
+     * @param attr
+     *            the attribute to check
+     * @param namespaceURI
+     *            see above
+     * @param name
+     *            see above
+     * @return <code>true</code> if the attribute matches, <code>false</code> otherwise
+     */
+    boolean matches(CoreAttribute attr, String namespaceURI, String name);
+
+    /**
+     * Get the <tt>namespaceURI</tt> parameter for an existing attribute. This method is used by
+     * {@link CoreElement#coreSetAttribute(AttributeMatcher, CoreAttribute, NodeMigrationPolicy, boolean, CoreDocument, com.googlecode.ddom.core.CoreElement.ReturnValue)}
+     * which passes its return value as parameter to {@link #matches(CoreAttribute, String, String)}.
+     * 
+     * @param attr the attribute
+     * @return the <tt>namespaceURI</tt> parameter to be passed to {@link #matches(CoreAttribute, String, String)}
+     */
+    String getNamespaceURI(CoreAttribute attr);
+    
+    /**
+     * Get the <tt>name</tt> parameter for an existing attribute. This method is used by
+     * {@link CoreElement#coreSetAttribute(AttributeMatcher, CoreAttribute, NodeMigrationPolicy, boolean, CoreDocument, com.googlecode.ddom.core.CoreElement.ReturnValue)}
+     * which passes its return value as parameter to {@link #matches(CoreAttribute, String, String)}.
+     * 
+     * @param attr the attribute
+     * @return the <tt>name</tt> parameter to be passed to {@link #matches(CoreAttribute, String, String)}
+     */
+    String getName(CoreAttribute attr);
+    
+    /**
+     * Create a new attribute node. The values of the <code>namespaceURI</code>, <code>name</code>,
+     * <code>prefix</code> and <code>value</code> parameters are those passed to
+     * {@link CoreElement#coreSetAttribute(AttributeMatcher, String, String, String, String)}.
+     * 
+     * @param nodeFactory
+     *            the node factory the should be used to create the attribute
+     * @param document
+     *            the document in which the attribute is created
+     * @param namespaceURI
+     *            see above
+     * @param name
+     *            see above
+     * @param prefix
+     *            see above
+     * @param value
+     *            see above
+     * @return
+     */
+    CoreAttribute createAttribute(NodeFactory nodeFactory, CoreDocument document, String namespaceURI, String name, String prefix, String value);
+    
+    /**
+     * Update an existing attribute. The values of the <code>prefix</code> and <code>value</code>
+     * parameters are those passed to
+     * {@link CoreElement#coreSetAttribute(AttributeMatcher, String, String, String, String)}.
+     * 
+     * @param attr
+     *            the attribute to update
+     * @param prefix
+     *            see above
+     * @param value
+     *            see above
+     * @throws DeferredParsingException
+     */
+    void update(CoreAttribute attr, String prefix, String value);
+}

Propchange: webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/AttributeMatcher.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreAttribute.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreAttribute.java?rev=1685220&r1=1685219&r2=1685220&view=diff
==============================================================================
--- webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreAttribute.java (original)
+++ webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreAttribute.java Sat Jun 13 08:48:15 2015
@@ -19,5 +19,54 @@
 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();
+
+    void coreSetValue(String value);
 }

Modified: webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreAttributeSupport.aj
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreAttributeSupport.aj?rev=1685220&r1=1685219&r2=1685220&view=diff
==============================================================================
--- webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreAttributeSupport.aj (original)
+++ webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreAttributeSupport.aj Sat Jun 13 08:48:15 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,63 @@ public aspect CoreAttributeSupport {
         owner = document;
     }
 
+    public final CoreAttribute CoreAttribute.coreGetNextAttribute() {
+        return 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;
+            }
+            return true;
+        } else {
+            if (newOwnerDocument) {
+                owner = ownerDocument;
+            }
+            return false;
+        }
+    }
+
     public final boolean CoreAttribute.coreGetSpecified() {
         return !getFlag(Flags.DEFAULT_ATTR);
     }

Modified: webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreElement.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreElement.java?rev=1685220&r1=1685219&r2=1685220&view=diff
==============================================================================
--- webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreElement.java (original)
+++ webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreElement.java Sat Jun 13 08:48:15 2015
@@ -19,5 +19,32 @@
 package org.apache.axiom.core;
 
 public interface CoreElement extends CoreChildNode, CoreParentNode {
+    /**
+     * 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();
+
+    /**
+     * 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;
 }

Added: webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreElementSupport.aj
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreElementSupport.aj?rev=1685220&view=auto
==============================================================================
--- webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreElementSupport.aj (added)
+++ webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreElementSupport.aj Sat Jun 13 08:48:15 2015
@@ -0,0 +1,91 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.axiom.core;
+
+public aspect CoreElementSupport {
+    private CoreAttribute CoreElement.firstAttribute;
+
+    public final CoreAttribute CoreElement.coreGetFirstAttribute() {
+        return firstAttribute;
+    }
+
+    final void CoreElement.internalSetFirstAttribute(CoreAttribute firstAttribute) {
+        this.firstAttribute = firstAttribute;
+    }
+
+    public final CoreAttribute CoreElement.coreGetLastAttribute() {
+        CoreAttribute previousAttribute = null;
+        CoreAttribute attribute = firstAttribute;
+        while (attribute != null) {
+            previousAttribute = attribute;
+            attribute = attribute.coreGetNextAttribute();
+        }
+        return previousAttribute;
+    }
+
+    private CoreAttribute CoreElement.accept(CoreAttribute attr, NodeMigrationPolicy policy) throws NodeMigrationException {
+        boolean hasParent = attr.coreHasOwnerElement();
+        boolean isForeignDocument = !coreHasSameOwnerDocument(attr);
+        boolean isForeignModel = attr.coreGetNodeFactory() != coreGetNodeFactory();
+        if (hasParent || isForeignDocument || isForeignModel) {
+            switch (policy.getAction(hasParent, isForeignDocument, isForeignModel)) {
+                case REJECT:
+                    if (isForeignDocument) {
+                        // Note that since isForeignModel implies isForeignDocument, we also get here
+                        // if isForeignModel is true.
+                        throw new WrongDocumentException();
+                    } else {
+                        // We get here if isForeignDocument and isForeignModel are false. Since at least
+                        // one of the three booleans must be true, this implies that hasParent is true.
+                        throw new NodeInUseException();
+                    }
+                case MOVE:
+                    if (isForeignDocument || isForeignModel) {
+                        // TODO
+//                        throw new UnsupportedOperationException();
+                        return attr;
+                    } else {
+                        attr.coreRemove();
+                        return attr;
+                    }
+                case CLONE:
+                    // TODO: probably we need to distinguish between cloning an attribute from the same model and importing it from another model (does that actually ever occur?)
+                    throw new UnsupportedOperationException();
+//                    return cloneAttribute(attr);
+                default:
+                    // Should never get here unless new values are added to the enum
+                    throw new IllegalStateException();
+            }
+        } else {
+            return attr;
+        }
+    }
+
+    public final void CoreElement.coreAppendAttribute(CoreAttribute attr, NodeMigrationPolicy policy) throws NodeMigrationException {
+        // TODO: we should probably check if the attribute is already owned by the element
+        attr = accept(attr, policy);
+        attr.internalSetOwnerElement(this);
+        CoreAttribute lastAttribute = coreGetLastAttribute();
+        if (lastAttribute == null) {
+            firstAttribute = attr;
+        } else {
+            lastAttribute.insertAttributeAfter(attr);
+        }
+    }
+}

Propchange: webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreElementSupport.aj
------------------------------------------------------------------------------
    svn:eol-style = native

Added: webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreModelException.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreModelException.java?rev=1685220&view=auto
==============================================================================
--- webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreModelException.java (added)
+++ webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreModelException.java Sat Jun 13 08:48:15 2015
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.axiom.core;
+
+/**
+ * Indicates an attempt to perform an invalid operation on the model. This exception is checked
+ * since the frontend implementation must translate any exception thrown by the backend
+ * implementation to an exception specific to the frontend API.
+ */
+public abstract class CoreModelException extends Exception {
+    private static final long serialVersionUID = 1204321445792058777L;
+
+    public CoreModelException() {
+    }
+
+    public CoreModelException(String message) {
+        super(message);
+    }
+
+    public CoreModelException(String message, Throwable cause) {
+        super(message, cause);
+    }
+
+    public CoreModelException(Throwable cause) {
+        super(cause);
+    }
+}

Propchange: webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreModelException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreNSAwareAttribute.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreNSAwareAttribute.java?rev=1685220&view=auto
==============================================================================
--- webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreNSAwareAttribute.java (added)
+++ webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreNSAwareAttribute.java Sat Jun 13 08:48:15 2015
@@ -0,0 +1,26 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.axiom.core;
+
+/**
+ * Represents a namespace aware attribute information item.
+ */
+public interface CoreNSAwareAttribute extends CoreTypedAttribute, CoreNSAwareNamedNode {
+
+}

Propchange: webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreNSAwareAttribute.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreNSAwareNamedNode.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreNSAwareNamedNode.java?rev=1685220&view=auto
==============================================================================
--- webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreNSAwareNamedNode.java (added)
+++ webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreNSAwareNamedNode.java Sat Jun 13 08:48:15 2015
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.axiom.core;
+
+/**
+ * Represents a namespace aware named information item.
+ */
+public interface CoreNSAwareNamedNode {
+    String coreGetNamespaceURI();
+    String coreGetPrefix();
+    void coreSetPrefix(String prefix);
+    String coreGetLocalName();
+}

Propchange: webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreNSAwareNamedNode.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreNSUnawareAttribute.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreNSUnawareAttribute.java?rev=1685220&view=auto
==============================================================================
--- webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreNSUnawareAttribute.java (added)
+++ webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreNSUnawareAttribute.java Sat Jun 13 08:48:15 2015
@@ -0,0 +1,26 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.axiom.core;
+
+/**
+ * Represents a namespace unaware attribute information item.
+ */
+public interface CoreNSUnawareAttribute extends CoreTypedAttribute, CoreNSUnawareNamedNode {
+
+}

Propchange: webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreNSUnawareAttribute.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreNSUnawareNamedNode.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreNSUnawareNamedNode.java?rev=1685220&view=auto
==============================================================================
--- webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreNSUnawareNamedNode.java (added)
+++ webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreNSUnawareNamedNode.java Sat Jun 13 08:48:15 2015
@@ -0,0 +1,26 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.axiom.core;
+
+/**
+ * Represents a namespace unaware named information item.
+ */
+public interface CoreNSUnawareNamedNode {
+    String coreGetName();
+}

Propchange: webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreNSUnawareNamedNode.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreNamespaceDeclaration.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreNamespaceDeclaration.java?rev=1685220&view=auto
==============================================================================
--- webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreNamespaceDeclaration.java (added)
+++ webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreNamespaceDeclaration.java Sat Jun 13 08:48:15 2015
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.axiom.core;
+
+/**
+ * Represents a namespace declaration information item.
+ */
+public interface CoreNamespaceDeclaration extends CoreAttribute {
+    /**
+     * Get the prefix declared by this namespace declaration.
+     * 
+     * @return the prefix, or <code>null</code> if this namespace declaration defines the default
+     *         namespace
+     */
+    String coreGetDeclaredPrefix();
+    
+    String coreGetDeclaredNamespaceURI();
+}

Propchange: webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreNamespaceDeclaration.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreTypedAttribute.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreTypedAttribute.java?rev=1685220&view=auto
==============================================================================
--- webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreTypedAttribute.java (added)
+++ webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreTypedAttribute.java Sat Jun 13 08:48:15 2015
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.axiom.core;
+
+/**
+ * Represents an attribute information item that is not a namespace declaration.
+ */
+public interface CoreTypedAttribute extends CoreAttribute {
+    String coreGetType();
+    void coreSetType(String type);
+}

Propchange: webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreTypedAttribute.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/NSAwareAttributeMatcher.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/NSAwareAttributeMatcher.java?rev=1685220&view=auto
==============================================================================
--- webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/NSAwareAttributeMatcher.java (added)
+++ webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/NSAwareAttributeMatcher.java Sat Jun 13 08:48:15 2015
@@ -0,0 +1,91 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.axiom.core;
+
+/**
+ * {@link AttributeMatcher} implementation that matches attributes based on their namespace URI and
+ * local name. Parameters are defined as follows:
+ * <dl>
+ * <dt><code>namespaceURI</code>
+ * <dd>The namespace URI of the attribute.
+ * <dt><code>name</code>
+ * <dd>The local name of the attribute.
+ * <dt><code>value</code>
+ * <dd>The attribute value.
+ * <dt><code>prefix</code>
+ * <dd>The prefix to be used when creating a new attribute or updating an existing one.
+ * </dl>
+ * If the namespace URI is the emtpy string, then this class will also match namespace unaware
+ * attributes. Note that the class doesn't match namespace declarations (for which
+ * {@link AttributeMatcher#NAMESPACE_DECLARATION} can be used).
+ */
+public final class NSAwareAttributeMatcher implements AttributeMatcher {
+    private final boolean matchNSUnawareAttributes;
+    private final boolean updatePrefix;
+    
+    /**
+     * Constructor.
+     * 
+     * @param matchNSUnawareAttributes
+     *            Specifies if {@link CoreNSUnawareAttribute} instances can also be matched. Only
+     *            applies to the case where <code>namespaceURI</code> is the empty string.
+     * @param updatePrefix
+     *            Specifies if the prefix of an existing attribute should be updated (based on the
+     *            value of the <code>prefix</code> parameter. If this is <code>false</code>, then
+     *            <code>prefix</prefix> is only used when creating new attributes and prefixes of
+     * existing attributes are preserved (i.e. only their value is updated).
+     */
+    public NSAwareAttributeMatcher(boolean matchNSUnawareAttributes, boolean updatePrefix) {
+        this.matchNSUnawareAttributes = matchNSUnawareAttributes;
+        this.updatePrefix = updatePrefix;
+    }
+    
+    public boolean matches(CoreAttribute attr, String namespaceURI, String name) {
+        if (attr instanceof CoreNSAwareAttribute) {
+            CoreNSAwareAttribute nsAwareAttr = (CoreNSAwareAttribute)attr;
+            // Optimization: first compare the local names because they are in general
+            // shorter and have higher "uniqueness"
+            return name.equals(nsAwareAttr.coreGetLocalName())
+                    && namespaceURI.equals(nsAwareAttr.coreGetNamespaceURI());
+        } else if (matchNSUnawareAttributes && namespaceURI.length() == 0 && attr instanceof CoreNSUnawareAttribute) {
+            return name.equals(((CoreNSUnawareAttribute)attr).coreGetName());
+        } else {
+            return false;
+        }
+    }
+
+    public String getNamespaceURI(CoreAttribute attr) {
+        return ((CoreNSAwareAttribute)attr).coreGetNamespaceURI();
+    }
+
+    public String getName(CoreAttribute attr) {
+        return ((CoreNSAwareAttribute)attr).coreGetLocalName();
+    }
+
+    public CoreAttribute createAttribute(NodeFactory nodeFactory, CoreDocument document, String namespaceURI, String name, String prefix, String value) {
+        return nodeFactory.createAttribute(document, namespaceURI, name, prefix, value, null);
+    }
+
+    public void update(CoreAttribute attr, String prefix, String value) {
+        attr.coreSetValue(value);
+        if (updatePrefix && attr instanceof CoreNSAwareAttribute) {
+            ((CoreNSAwareAttribute)attr).coreSetPrefix(prefix);
+        }
+    }
+}

Propchange: webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/NSAwareAttributeMatcher.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/NodeFactory.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/NodeFactory.java?rev=1685220&r1=1685219&r2=1685220&view=diff
==============================================================================
--- webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/NodeFactory.java (original)
+++ webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/NodeFactory.java Sat Jun 13 08:48:15 2015
@@ -22,4 +22,6 @@ public interface NodeFactory {
     CoreDocument createDocument();
     CoreCharacterData createCharacterData();
     CoreCDATASection createCDATASection();
+    CoreNSAwareAttribute createAttribute(CoreDocument document, String namespaceURI, String localName, String prefix, String value, String type);
+    CoreNamespaceDeclaration createNamespaceDeclaration(CoreDocument document, String prefix, String namespaceURI);
 }

Added: webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/NodeInUseException.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/NodeInUseException.java?rev=1685220&view=auto
==============================================================================
--- webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/NodeInUseException.java (added)
+++ webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/NodeInUseException.java Sat Jun 13 08:48:15 2015
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.axiom.core;
+
+/**
+ * Indicates that a request to insert a node could not be fulfilled because the node is already
+ * owned by another node in the same document. Whether or not this exception may be thrown by a
+ * method depends on the provided {@link NodeMigrationPolicy} implementation.
+ */
+public class NodeInUseException extends NodeMigrationException {
+    private static final long serialVersionUID = 3857141874280465603L;
+
+    public NodeInUseException() {
+    }
+
+    public NodeInUseException(String message) {
+        super(message);
+    }
+}

Propchange: webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/NodeInUseException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/NodeMigrationException.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/NodeMigrationException.java?rev=1685220&view=auto
==============================================================================
--- webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/NodeMigrationException.java (added)
+++ webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/NodeMigrationException.java Sat Jun 13 08:48:15 2015
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.axiom.core;
+
+/**
+ * Indicates that a request to insert a node could not be fulfilled. Exceptions of this type are
+ * thrown when {@link NodeMigrationPolicy#getAction(boolean, boolean, boolean)} returns
+ * {@link NodeMigrationPolicy.Action#REJECT}.
+ */
+public abstract class NodeMigrationException extends CoreModelException {
+    private static final long serialVersionUID = -1075697096493216501L;
+
+    public NodeMigrationException() {
+    }
+
+    public NodeMigrationException(String message) {
+        super(message);
+    }
+}

Propchange: webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/NodeMigrationException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/NodeMigrationPolicy.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/NodeMigrationPolicy.java?rev=1685220&view=auto
==============================================================================
--- webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/NodeMigrationPolicy.java (added)
+++ webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/NodeMigrationPolicy.java Sat Jun 13 08:48:15 2015
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.axiom.core;
+
+/**
+ * Defines the policy to apply when the core model is requested to insert a node that already has a
+ * parent or is owned by a different document.
+ */
+public interface NodeMigrationPolicy {
+    enum Action {
+        /**
+         * Reject the operation and trigger an appropriate exception.
+         * TODO: specify exceptions
+         */
+        REJECT,
+
+        /**
+         * Move the node. If the node is owned by the same document, it will simply be detached from
+         * its parent using {@link CoreChildNode#coreDetach()}. If it is owned by a different
+         * document, it will be adopted using [TODO]. This action is only applicable if the node is
+         * an instance from the same model.
+         */
+        MOVE,
+        
+        /**
+         * Clone the node, i.e. insert a (deep) copy instead of the original node.
+         * TODO: specify methods that will be used
+         */
+        CLONE
+    }
+    
+    NodeMigrationPolicy MOVE_ALWAYS = new NodeMigrationPolicy() {
+        public Action getAction(boolean hasParent, boolean isForeignDocument, boolean isForeignModel) {
+            return Action.MOVE;
+        }
+    };
+    
+    /**
+     * 
+     * @param hasParent
+     *            <code>true</code> if the node to migrate has a parent (or an owner element in the
+     *            case of {@link CoreAttribute}); <code>false</code> if the node is detached
+     * @param isForeignDocument
+     *            <code>true</code> if the node to migrate belongs to a different document
+     * @param isForeignModel
+     *            <code>true</code> if the node to migrate belongs to a different model. Note that
+     *            this parameter can only be <code>true</code> if <code>isForeignDocument</code> is
+     *            also <code>true</code>
+     * @return
+     */
+    Action getAction(boolean hasParent, boolean isForeignDocument, boolean isForeignModel);
+}

Propchange: webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/NodeMigrationPolicy.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/WrongDocumentException.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/WrongDocumentException.java?rev=1685220&view=auto
==============================================================================
--- webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/WrongDocumentException.java (added)
+++ webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/WrongDocumentException.java Sat Jun 13 08:48:15 2015
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.axiom.core;
+
+/**
+ * Indicates that a request to insert a node could not be fulfilled because the node belongs to a
+ * different document. Whether or not this exception may be thrown by a method depends on the
+ * provided {@link NodeMigrationPolicy} implementation.
+ */
+public class WrongDocumentException extends NodeMigrationException {
+    private static final long serialVersionUID = -7135259787609333075L;
+
+    public WrongDocumentException() {
+    }
+
+    public WrongDocumentException(String message) {
+        super(message);
+    }
+}

Propchange: webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/WrongDocumentException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: webservices/axiom/branches/attrs-aspects/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/AttributesNamedNodeMap.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/attrs-aspects/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/AttributesNamedNodeMap.java?rev=1685220&view=auto
==============================================================================
--- webservices/axiom/branches/attrs-aspects/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/AttributesNamedNodeMap.java (added)
+++ webservices/axiom/branches/attrs-aspects/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/AttributesNamedNodeMap.java Sat Jun 13 08:48:15 2015
@@ -0,0 +1,99 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.axiom.dom;
+
+import org.apache.axiom.core.CoreAttribute;
+import org.apache.axiom.core.CoreTypedAttribute;
+import org.w3c.dom.Attr;
+import org.w3c.dom.DOMException;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+
+final class AttributesNamedNodeMap implements NamedNodeMap {
+    private final DOMElement element;
+    
+    AttributesNamedNodeMap(DOMElement element) {
+        this.element = element;
+    }
+
+    public int getLength() {
+        int length = 0;
+        CoreAttribute attr = element.coreGetFirstAttribute();
+        while (attr != null) {
+            attr = attr.coreGetNextAttribute();
+            length++;
+        }
+        return length;
+    }
+    
+    public Node item(int index) {
+        // TODO: wrong result for negative indexes
+        CoreAttribute attr = element.coreGetFirstAttribute();
+        for (int i=0; i<index && attr != null; i++) {
+            attr = attr.coreGetNextAttribute();
+        }
+        return (Node)attr;
+    }
+
+    public Node getNamedItem(String name) {
+        return element.getAttributeNode(name);
+    }
+
+    public Node getNamedItemNS(String namespaceURI, String localName) throws DOMException {
+        return element.getAttributeNodeNS(namespaceURI, localName);
+    }
+
+    public Node setNamedItem(Node arg) throws DOMException {
+        if (arg instanceof CoreTypedAttribute) {
+            return element.setAttributeNode((Attr)arg);
+        } else {
+            throw DOMExceptionUtil.newDOMException(DOMException.HIERARCHY_REQUEST_ERR);
+        }
+    }
+
+    public Node setNamedItemNS(Node arg) throws DOMException {
+        if (arg instanceof CoreTypedAttribute) {
+            return element.setAttributeNodeNS((Attr)arg);
+        } else {
+            throw DOMExceptionUtil.newDOMException(DOMException.HIERARCHY_REQUEST_ERR);
+        }
+    }
+
+    public Node removeNamedItem(String name) throws DOMException {
+        // TODO: try to merge with corresponding method in ElementImpl
+        Attr attr = element.getAttributeNode(name);
+        if (attr != null) {
+            element.removeAttributeNode(attr);
+            return attr;
+        } else {
+            throw DOMExceptionUtil.newDOMException(DOMException.NOT_FOUND_ERR);
+        }
+    }
+
+    public Node removeNamedItemNS(String namespaceURI, String localName) throws DOMException {
+        // TODO: try to merge with corresponding method in ElementImpl
+        Attr attr = element.getAttributeNodeNS(namespaceURI, localName);
+        if (attr != null) {
+            element.removeAttributeNode(attr);
+            return attr;
+        } else {
+            throw DOMExceptionUtil.newDOMException(DOMException.NOT_FOUND_ERR);
+        }
+    }
+}

Propchange: webservices/axiom/branches/attrs-aspects/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/AttributesNamedNodeMap.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: webservices/axiom/branches/attrs-aspects/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/DOMElementSupport.aj
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/attrs-aspects/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/DOMElementSupport.aj?rev=1685220&r1=1685219&r2=1685220&view=diff
==============================================================================
--- webservices/axiom/branches/attrs-aspects/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/DOMElementSupport.aj (original)
+++ webservices/axiom/branches/attrs-aspects/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/DOMElementSupport.aj Sat Jun 13 08:48:15 2015
@@ -118,6 +118,14 @@ public aspect DOMElementSupport {
         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 String DOMElement.getAttribute(String name) {
         Attr attr = getAttributeNode(name);
         return attr != null ? attr.getValue() : "";

Modified: webservices/axiom/branches/attrs-aspects/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/DOMExceptionUtil.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/attrs-aspects/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/DOMExceptionUtil.java?rev=1685220&r1=1685219&r2=1685220&view=diff
==============================================================================
--- webservices/axiom/branches/attrs-aspects/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/DOMExceptionUtil.java (original)
+++ webservices/axiom/branches/attrs-aspects/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/DOMExceptionUtil.java Sat Jun 13 08:48:15 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());
+        }
+    }
 }

Added: webservices/axiom/branches/attrs-aspects/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/DOMNamespaceDeclaration.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/attrs-aspects/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/DOMNamespaceDeclaration.java?rev=1685220&view=auto
==============================================================================
--- webservices/axiom/branches/attrs-aspects/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/DOMNamespaceDeclaration.java (added)
+++ webservices/axiom/branches/attrs-aspects/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/DOMNamespaceDeclaration.java Sat Jun 13 08:48:15 2015
@@ -0,0 +1,25 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.axiom.dom;
+
+import org.apache.axiom.core.CoreNamespaceDeclaration;
+
+public interface DOMNamespaceDeclaration extends DOMAttribute, CoreNamespaceDeclaration {
+
+}

Propchange: webservices/axiom/branches/attrs-aspects/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/DOMNamespaceDeclaration.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: webservices/axiom/branches/attrs-aspects/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/DOMNamespaceDeclarationSupport.aj
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/attrs-aspects/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/DOMNamespaceDeclarationSupport.aj?rev=1685220&view=auto
==============================================================================
--- webservices/axiom/branches/attrs-aspects/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/DOMNamespaceDeclarationSupport.aj (added)
+++ webservices/axiom/branches/attrs-aspects/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/DOMNamespaceDeclarationSupport.aj Sat Jun 13 08:48:15 2015
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.axiom.dom;
+
+import javax.xml.XMLConstants;
+
+import org.w3c.dom.DOMException;
+
+public aspect DOMNamespaceDeclarationSupport {
+    public final String DOMNamespaceDeclaration.getNamespaceURI() {
+        return XMLConstants.XMLNS_ATTRIBUTE_NS_URI;
+    }
+
+    public final String DOMNamespaceDeclaration.getPrefix() {
+        return coreGetDeclaredPrefix().length() == 0 ? null : XMLConstants.XMLNS_ATTRIBUTE;
+    }
+
+    public final void DOMNamespaceDeclaration.setPrefix(String prefix) throws DOMException {
+        // Other DOM implementations allow changing the prefix, but this means that a namespace
+        // declaration is transformed into a normal attribute. We don't support this.
+        throw DOMExceptionUtil.newDOMException(DOMException.NAMESPACE_ERR);
+    }
+
+    public final String DOMNamespaceDeclaration.getLocalName() {
+        String declaredPrefix = coreGetDeclaredPrefix();
+        return declaredPrefix.length() == 0 ? XMLConstants.XMLNS_ATTRIBUTE : declaredPrefix;
+    }
+
+    public final String DOMNamespaceDeclaration.getName() {
+        String declaredPrefix = coreGetDeclaredPrefix();
+        if (declaredPrefix.length() == 0) {
+            return XMLConstants.XMLNS_ATTRIBUTE;
+        } else {
+            return XMLConstants.XMLNS_ATTRIBUTE + ":" + declaredPrefix;
+        }
+    }
+}

Propchange: webservices/axiom/branches/attrs-aspects/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/DOMNamespaceDeclarationSupport.aj
------------------------------------------------------------------------------
    svn:eol-style = native

Added: webservices/axiom/branches/attrs-aspects/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/Policies.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/attrs-aspects/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/Policies.java?rev=1685220&view=auto
==============================================================================
--- webservices/axiom/branches/attrs-aspects/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/Policies.java (added)
+++ webservices/axiom/branches/attrs-aspects/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/Policies.java Sat Jun 13 08:48:15 2015
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.axiom.dom;
+
+import org.apache.axiom.core.AttributeMatcher;
+import org.apache.axiom.core.NSAwareAttributeMatcher;
+
+public final class Policies {
+    private Policies() {}
+    
+    public static final AttributeMatcher DOM2_ATTRIBUTE_MATCHER = new NSAwareAttributeMatcher(true, true);
+}

Propchange: webservices/axiom/branches/attrs-aspects/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/Policies.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: webservices/axiom/branches/attrs-aspects/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/AttrImpl.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/attrs-aspects/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/AttrImpl.java?rev=1685220&r1=1685219&r2=1685220&view=diff
==============================================================================
--- webservices/axiom/branches/attrs-aspects/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/AttrImpl.java (original)
+++ webservices/axiom/branches/attrs-aspects/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/AttrImpl.java Sat Jun 13 08:48:15 2015
@@ -42,73 +42,17 @@ 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 {
+    String type;
 
     /** 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
     // /
@@ -189,23 +133,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.
@@ -273,6 +200,10 @@ public class AttrImpl extends RootNode i
         setTextContent(value);
     }
 
+    public final void coreSetValue(String value) {
+        setValue(value);
+    }
+
     /*
      * DOM-Level 3 methods
      */
@@ -285,84 +216,10 @@ public class AttrImpl extends RootNode i
         return isId;
     }
 
-    public String toString() {
-        OMNamespace namespace = getNamespace();
-        String localName = getLocalName();
-        return (namespace == null) ? localName : namespace
-                .getPrefix()
-                + ":" + localName;
-    }
-
-    /**
-     * An instance of <code>AttrImpl</code> can act as an <code>OMAttribute</code> and as well as an
-     * <code>org.w3c.dom.Attr</code>. So we first check if the object to compare with (<code>obj</code>)
-     * is of type <code>OMAttribute</code> (this includes instances of <code>OMAttributeImpl</code> or
-     * <code>AttrImpl</code> (instances of this class)). If so we check for the equality
-     * of namespaces first (note that if the namespace of this instance is null then for the <code>obj</code>
-     * to be equal its namespace must also be null). This condition solely doesn't determine the equality.
-     * So we check for the equality of names and values (note that the value can also be null in which case
-     * the same argument holds as that for the namespace) of the two instances. If all three conditions are
-     * met then we say the two instances are equal.
-     *
-     * <p>If <code>obj</code> is of type <code>org.w3c.dom.Attr</code> then we perform the same equality check
-     * as before. Note that, however, the implementation of the test for equality in this case is little different
-     * than before.
-     *
-     * <p>If <code>obj</code> is neither of type <code>OMAttribute</code> nor of type <code>org.w3c.dom.Attr</code>
-     * then we return false.
-     *
-     * @param obj The object to compare with this instance
-     * @return True if the two objects are equal or else false. The equality is checked as explained above.
-     */
-    public boolean equals(Object obj) {
-        OMNamespace namespace = getNamespace();
-        String localName = getLocalName();
-        String attrValue = getValue();
-        if (obj instanceof OMAttribute) { // Checks equality of an OMAttributeImpl or an AttrImpl with this instance
-            OMAttribute other = (OMAttribute) obj;
-            return (namespace == null ? other.getNamespace() == null :
-                    namespace.equals(other.getNamespace()) &&
-                    localName.equals(other.getLocalName()) &&
-                    (attrValue == null ? other.getAttributeValue() == null :
-                            attrValue.toString().equals(other.getAttributeValue())));
-        } else if (obj instanceof Attr) {// Checks equality of an org.w3c.dom.Attr with this instance
-            Attr other = (Attr)obj;
-            String otherNs = other.getNamespaceURI();
-            if (namespace == null) { // I don't have a namespace
-                if (otherNs != null) {
-                    return false; // I don't have a namespace and the other has. So return false
-                } else {
-                    // Both of us don't have namespaces. So check for name and value equality only
-                    return (localName.equals(other.getLocalName()) &&
-                            (attrValue == null ? other.getValue() == null :
-                                    attrValue.toString().equals(other.getValue())));
-                }
-            } else { // Ok, now I've a namespace
-                String ns = namespace.getNamespaceURI();
-                String prefix = namespace.getPrefix();
-                String otherPrefix = other.getPrefix();
-                // First check for namespaceURI equality. Then check for prefix equality.
-                // Then check for name and value equality
-                return (ns.equals(otherNs) && (prefix == null ? otherPrefix == null : prefix.equals(otherPrefix)) &&
-                        (localName.equals(other.getLocalName())) &&
-                        (attrValue == null ? other.getValue() == null :
-                                attrValue.toString().equals(other.getValue())));
-            }
-        }
-        return false;
-    }
-
-    public int hashCode() {
-        OMNamespace namespace = getNamespace();
-        String localName = getLocalName();
-        String attrValue = getValue();
-        return localName.hashCode() ^ (attrValue != null ? attrValue.toString().hashCode() : 0) ^
-                (namespace != null ? namespace.hashCode() : 0);
-    }
-
     ParentNode shallowClone(OMCloneOptions options, ParentNode targetParent, boolean namespaceRepairing) {
         // Note: targetParent is always null here
-        return new AttrImpl(getLocalName(), getNamespace(), type, getOMFactory());
+        // TODO
+        return new NSAwareAttribute(getLocalName(), getNamespace(), type, getOMFactory());
     }
 
     public final boolean isComplete() {

Modified: webservices/axiom/branches/attrs-aspects/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DocumentImpl.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/attrs-aspects/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DocumentImpl.java?rev=1685220&r1=1685219&r2=1685220&view=diff
==============================================================================
--- webservices/axiom/branches/attrs-aspects/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DocumentImpl.java (original)
+++ webservices/axiom/branches/attrs-aspects/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DocumentImpl.java Sat Jun 13 08:48:15 2015
@@ -97,7 +97,7 @@ public class DocumentImpl extends RootNo
         if (!DOMUtil.isQualifiedName(name)) {
             throw newDOMException(DOMException.INVALID_CHARACTER_ERR);
         }
-        return new AttrImpl(this, name, getOMFactory());
+        return new NSAwareAttribute(this, name, getOMFactory());
     }
 
     public Attr createAttributeNS(String namespaceURI, String qualifiedName)
@@ -112,7 +112,7 @@ public class DocumentImpl extends RootNo
         } else {
             namespace = new OMNamespaceImpl(namespaceURI, prefix == null ? "" : prefix);
         }
-        return new AttrImpl(this, localName, namespace, getOMFactory());
+        return new NSAwareAttribute(this, localName, namespace, getOMFactory());
     }
 
     public Comment createComment(String data) {

Modified: webservices/axiom/branches/attrs-aspects/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ElementImpl.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/attrs-aspects/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ElementImpl.java?rev=1685220&r1=1685219&r2=1685220&view=diff
==============================================================================
--- webservices/axiom/branches/attrs-aspects/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ElementImpl.java (original)
+++ webservices/axiom/branches/attrs-aspects/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ElementImpl.java Sat Jun 13 08:48:15 2015
@@ -21,8 +21,11 @@ package org.apache.axiom.om.impl.dom;
 
 import static org.apache.axiom.dom.DOMExceptionUtil.newDOMException;
 
+import org.apache.axiom.core.NodeMigrationException;
+import org.apache.axiom.core.NodeMigrationPolicy;
 import org.apache.axiom.dom.DOMConfigurationImpl;
 import org.apache.axiom.dom.DOMElement;
+import org.apache.axiom.dom.DOMExceptionUtil;
 import org.apache.axiom.om.OMAttribute;
 import org.apache.axiom.om.OMCloneOptions;
 import org.apache.axiom.om.OMConstants;
@@ -44,7 +47,6 @@ import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.w3c.dom.Attr;
 import org.w3c.dom.DOMException;
-import org.w3c.dom.NamedNodeMap;
 
 import javax.xml.XMLConstants;
 import javax.xml.namespace.QName;
@@ -215,7 +217,7 @@ public class ElementImpl extends ParentN
         } else if (name.equals(XMLConstants.XMLNS_ATTRIBUTE)) {
             this.declareDefaultNamespace(value);
         } else {
-            this.setAttributeNode(new AttrImpl(ownerDocument(), name, value,
+            this.setAttributeNode(new NSAwareAttribute(ownerDocument(), name, value,
                                                getOMFactory()));
         }
 
@@ -273,7 +275,7 @@ public class ElementImpl extends ParentN
             attr.setValue(value);
         } else {
             if (namespaceURI != null) {
-                attr = new AttrImpl(ownerDocument(), localName, value, getOMFactory());
+                attr = new NSAwareAttribute(ownerDocument(), localName, value, getOMFactory());
                 attr.internalSetNamespace(new OMNamespaceImpl(namespaceURI, prefix == null ? "" : prefix));
     
                 this.setAttributeNodeNS(attr);
@@ -287,11 +289,6 @@ public class ElementImpl extends ParentN
 
     }
 
-    /** Returns whether this element contains any attribute or not. */
-    public boolean hasAttributes() {
-        return attributes != null && attributes.getLength() > 0;
-    }
-
     // /
     // /OmElement methods
     // /
@@ -305,7 +302,7 @@ public class ElementImpl extends ParentN
             if (owner == this) {
                 return attr;
             }
-            attr = new AttrImpl(null, attr.getLocalName(), attr.getNamespace(),
+            attr = new NSAwareAttribute(null, attr.getLocalName(), attr.getNamespace(),
                     attr.getAttributeValue(), attr.getOMFactory());
         }
         
@@ -338,7 +335,7 @@ public class ElementImpl extends ParentN
                 }
             }
         }
-        return addAttribute(new AttrImpl(null, localName, namespace, value, getOMFactory()));
+        return addAttribute(new NSAwareAttribute(null, localName, namespace, value, getOMFactory()));
     }
 
     public OMNamespace addNamespaceDeclaration(String uri, String prefix) {
@@ -348,8 +345,11 @@ public class ElementImpl extends ParentN
     }
     
     public void addNamespaceDeclaration(OMNamespace ns) {
-        String prefix = ns.getPrefix();
-        setAttributeNS(XMLConstants.XMLNS_ATTRIBUTE_NS_URI, prefix.length() == 0 ? XMLConstants.XMLNS_ATTRIBUTE : XMLConstants.XMLNS_ATTRIBUTE + ":" + prefix, ns.getNamespaceURI());
+        try {
+            coreAppendAttribute(new NamespaceDeclaration(null, ns, getOMFactory()), NodeMigrationPolicy.MOVE_ALWAYS);
+        } catch (NodeMigrationException ex) {
+            throw DOMExceptionUtil.translate(ex);
+        }
     }
 
     /**
@@ -524,9 +524,9 @@ public class ElementImpl extends ParentN
         }
 
         if (qname.getNamespaceURI().equals("")) {
-            return (AttrImpl) this.getAttributeNode(qname.getLocalPart());
+            return (NSAwareAttribute) this.getAttributeNode(qname.getLocalPart());
         } else {
-            return (AttrImpl) this.getAttributeNodeNS(qname.getNamespaceURI(),
+            return (NSAwareAttribute) this.getAttributeNodeNS(qname.getNamespaceURI(),
                                                       qname.getLocalPart());
         }
     }
@@ -638,11 +638,6 @@ public class ElementImpl extends ParentN
         return lineNumber;
     }
 
-    /** Returns the set of attributes of this node and the namespace declarations available. */
-    public NamedNodeMap getAttributes() {
-        return attributes;
-    }
-
     /**
      * Returns the namespace uri, given the prefix. If it is not found at this element, searches the
      * parent.