Element () { Element element = new Element(); element.attributes = new AttributeList(element); element.name = getName(); element.namespace = getNamespace(); // Cloning attributes List<Attribute> attributes = getAttributes(); if (attributes != null) { for (final Attribute attribute : attributes) { element.attributes.add(attribute.clone()); } } // Cloning additional namespaces if (additionalNamespaces != null) { element.additionalNamespaces = new ArrayList<>(additionalNamespaces); } // Cloning content for (Content c : myContent) { element.content.add(c.clone()); } return element; }