bug 253753: also clone the namespace declarations of an element

Signed-off-by: Florian Thienel <florian@thienel.org>
diff --git a/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src/org/eclipse/wst/xml/vex/core/internal/dom/Element.java b/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src/org/eclipse/wst/xml/vex/core/internal/dom/Element.java
index e0ac310..b9293b0 100644
--- a/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src/org/eclipse/wst/xml/vex/core/internal/dom/Element.java
+++ b/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src/org/eclipse/wst/xml/vex/core/internal/dom/Element.java
@@ -60,6 +60,12 @@
 			//add the attributes to the element instance to be cloned
 			for (Map.Entry<QualifiedName, Attribute> attr : this.attributes.entrySet())
 				element.setAttribute(attr.getKey(), attr.getValue().getValue());
+			for (Map.Entry<String, String> namespaceDeclaration : this.namespaceDeclarations.entrySet()) {
+				if (namespaceDeclaration.getKey() == null)
+					element.declareDefaultNamespace(namespaceDeclaration.getValue());
+				else
+					element.declareNamespace(namespaceDeclaration.getKey(), namespaceDeclaration.getValue());
+			}
 			return element;
 		} catch (DocumentValidationException ex) {
 			ex.printStackTrace();
diff --git a/sourceediting/tests/org.eclipse.wst.xml.vex.core.tests/src/org/eclipse/wst/xml/vex/core/internal/dom/NamespaceTest.java b/sourceediting/tests/org.eclipse.wst.xml.vex.core.tests/src/org/eclipse/wst/xml/vex/core/internal/dom/NamespaceTest.java
index 7e044f5..a06a69a 100644
--- a/sourceediting/tests/org.eclipse.wst.xml.vex.core.tests/src/org/eclipse/wst/xml/vex/core/internal/dom/NamespaceTest.java
+++ b/sourceediting/tests/org.eclipse.wst.xml.vex.core.tests/src/org/eclipse/wst/xml/vex/core/internal/dom/NamespaceTest.java
@@ -223,6 +223,18 @@
 	}

 

 	@Test

+	public void cloneElementsNamespaceDeclarations() throws Exception {

+		final Element element = new Element("element");

+		element.declareDefaultNamespace("http://namespace/uri/default");

+		element.declareNamespace("ns1", "http://namespace/uri/1");

+		element.declareNamespace("ns2", "http://namespace/uri/2");

+		

+		final Element clone = (Element) element.clone();

+		assertEquals("http://namespace/uri/default", clone.getDeclaredDefaultNamespaceURI());

+		

+	}

+	

+	@Test

 	public void readNamespaceDeclarations() throws Exception {

 		final Document document = readDocumentFromString("<ns1:a xmlns=\"http://namespace/default\" xmlns:ns1=\"http://namespace/uri/1\"/>");

 		final Element rootElement = document.getRootElement();