[458658] Removing obsolete objects before reassigning XML IDs.
diff --git a/plugins/org.eclipse.uml2.uml/src/org/eclipse/uml2/uml/internal/operations/PackageOperations.java b/plugins/org.eclipse.uml2.uml/src/org/eclipse/uml2/uml/internal/operations/PackageOperations.java
index 9352cee..2818f40 100644
--- a/plugins/org.eclipse.uml2.uml/src/org/eclipse/uml2/uml/internal/operations/PackageOperations.java
+++ b/plugins/org.eclipse.uml2.uml/src/org/eclipse/uml2/uml/internal/operations/PackageOperations.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2014 IBM Corporation, Embarcadero Technologies, CEA, and others.
+ * Copyright (c) 2005, 2015 IBM Corporation, Embarcadero Technologies, CEA, and others.
  * All rights reserved.   This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
  * which accompanies this distribution, and is available at
@@ -9,7 +9,7 @@
  *   IBM - initial API and implementation
  *   Kenn Hussey (Embarcadero Technologies) - 271470
  *   Kenn Hussey - 323181, 348433
- *   Kenn Hussey (CEA) - 327039, 369492, 313951, 163556, 418466, 447901
+ *   Kenn Hussey (CEA) - 327039, 369492, 313951, 163556, 418466, 447901, 458658
  *   Christian W. Damus (CEA) - 300957, 431998
  *
  */
@@ -714,7 +714,9 @@
 
 			if (eResource instanceof XMLResource) {
 				XMLResource xmlResource = (XMLResource) eResource;
-				xmlResource.setID(copy, xmlResource.getID(key));
+				String id = xmlResource.getID(key);
+				xmlResource.setID(key, null);
+				xmlResource.setID(copy, id);
 			}
 
 			for (Setting setting : new ArrayList<EStructuralFeature.Setting>(