copy = new JexXmlResource(original.getURI().trimFileExtension().appendFileExtension(extension));
copy.getContents().addAll(EcoreUtil.copyAll(original.getContents()));
ResourceSet resourceSet = new ResourceSetImpl();
resourceSet.getResources().add(copy);
// set up extension
ExtendedMetaData extendedMetaData = new BasicExtendedMetaData(resourceSet.getPackageRegistry());
resourceSet.getLoadOptions().put(XMLResource.OPTION_EXTENDED_META_DATA, extendedMetaData);
Map extensions = copy.getEObjectToExtensionMap();
// create extension attribute meta object
EStructuralFeature originalAttributeFeature = extendedMetaData.demandFeature(null, "original", false);
// create extension attribute
AnyType originalAttribute = XMLTypeFactory.eINSTANCE.createAnyType();
// set extension attribute value
originalAttribute.eSet(originalAttributeFeature, original.getURI().toString());
// add attribute to root object