ElementImpl extends NodeImpl implements Element { public Object clone() { ElementImpl clone = (ElementImpl) super.clone(); clone.attributes = new TreeMap<NSName, Attribute>(); for (Attribute attribute : attributes.values()) { AttributeImpl attributeImpl = (AttributeImpl) attribute; clone.setAttribute((AttributeImpl) attributeImpl.clone()); } clone.namespace2Prefix = new TreeMap<String, String>(namespace2Prefix); clone.prefix2Namespace = new TreeMap<String, String>(prefix2Namespace); clone.cloneChildrenFrom(this); return clone; } protected  ElementImpl(String namespaceUri, String prefix, String name); protected  ElementImpl(String namespaceUri, String name,
			org.w3c.dom.Element xmlElement); String getNamespaceUri(); String getPrefix(); String getName(); Map<String, String> getNamespacePrefixMapping(); void setNamespacePrefixMapping(Map<String, String> namespace2Prefix); Collection<? extends Attribute> getAttributes(); abstract List<? extends Node> getChildren(); org.w3c.dom.Element asXmlNode(Document document); Object clone(); @Override int hashCode(); @Override boolean equals(Object obj); @Override String toString();  }
@Test public void testClone() { ConcreteElementImpl parent = new ConcreteElementImpl("ns", null, "name"); ConcreteElementImpl elem = new ConcreteElementImpl("ns", null, "name"); parent.addChild(elem); ConcreteElementImpl celem = elem.clone(); assertNull(celem.getParentElement()); assertEquals(elem, celem); assertNotSame(elem, celem); }