URI referencedURI = ImportHelper.makeURICanonical(referenced.getURI());
Definitions importedDef = ImportHelper.getDefinitions(referenced);
// only handle BPMN imports (with declared target namespace)
if (importedDef != null && importedDef.getTargetNamespace() != null) {
Import newImport = Bpmn2Factory.eINSTANCE.createImport();
newImport.setImportType(NamespaceHelper.xmiToXsdNamespaceUri(Bpmn2Package.eNS_URI));
newImport.setNamespace(importedDef.getTargetNamespace());
// Counterpart: location.resolve(referencingURI) == referencedURI !
newImport.setLocation(referencedURI.deresolve(referencingURI).toString());
definitions.getImports().add(newImport);
}
}
}