src/main/java/org/jboss/util/xml/DOMUtils.java
public static void copyAttributes(Element destElement, Element srcElement)
    {
        NamedNodeMap attribs = srcElement.getAttributes();
        for (int i = 0; i < attribs.getLength(); i++)
        {
            Attr attr = (Attr)attribs.item(i);
            String uri = attr.getNamespaceURI();
            String qname = attr.getName();
            String value = attr.getNodeValue();
            
            // Prevent DOMException: NAMESPACE_ERR: An attempt is made to create or 
            // change an object in a way which is incorrect with regard to namespaces.
            if (uri == null && qname.startsWith("xmlns"))
            {
               log.trace("Ignore attribute: [uri=" + uri + ",qname=" + qname + ",value=" + value + "]");
            }
            else
            {
               destElement.setAttributeNS(uri, qname, value);
            }
        }
    }
public static void copyAttributes(Element destElement, Element srcElement)
    {
        NamedNodeMap attribs = srcElement.getAttributes();
        for (int i = 0; i < attribs.getLength(); i++)
        {
            Attr attr = (Attr)attribs.item(i);
            String uri = attr.getNamespaceURI();
            String qname = attr.getName();
            String value = attr.getNodeValue();
            
            // Prevent DOMException: NAMESPACE_ERR: An attempt is made to create or 
            // change an object in a way which is incorrect with regard to namespaces.
            if (uri == null && qname.startsWith("xmlns"))
            {
               log.trace("Ignore attribute: [uri=" + uri + ",qname=" + qname + ",value=" + value + "]");
            }
            else
            {
               destElement.setAttributeNS(uri, qname, value);
            }
        }
    }
public static void copyAttributes ( Element destElement , Element srcElement ) { NamedNodeMap attribs = srcElement . getAttributes ( ) ; for ( int i = 0 ; i < attribs . getLength ( ) ; i ++ ) { Attr attr = ( Attr ) attribs . item ( i ) ; String uri = attr . getNamespaceURI ( ) ; String qname = attr . getName ( ) ; String value = attr . getNodeValue ( ) ; // Prevent DOMException: NAMESPACE_ERR: An attempt is made to create or  // change an object in a way which is incorrect with regard to namespaces. if ( uri == null && qname . startsWith ( "xmlns" ) ) { log . trace ( "Ignore attribute: [uri=" + uri + ",qname=" + qname + ",value=" + value + "]" ) ; } else { destElement . setAttributeNS ( uri , qname , value ) ; } } }
Copy attributes between elements
@param destElement
@param srcElement
Copy attributes between elements