Dear Henshin team,
I have used the higher-order transformation technology of Henshin language to deduce rules and generate Henshin files, which contain several model rules, from any given model (Ecore file). The problem is that the generated Henshin files work with the path of the given model (Ecore file). Therefore, the model (Ecore file) should be always beside (i.e. in the right path to) the Henshin files.
How can I tell the interpreter to use the NS URI instead of the path of any selected model ? Or Is it possible to let the user to choose the path of any model and then register it so that the Henshin interpreter uses the NS URI? How can I generate Henshin files which work with the NS URI of the selected model?
In other words, the imports should not contain the path of the Ecore file. <imports href="model/MyRoom.ecore#/"/>
Please note that I do not want to write inside the following method too specific code such as MyroomPackageImpl.init() because this method should work correctly with any provided model.
I have used the following method to generate the Henshin files:
public static void run(String path, String ecoreLocalPath, String henshinLocalPath, String generatedHenshinfilesLocalPath, boolean saveResult) {
HenshinResourceSet resourceSet = new HenshinResourceSet(path);
resourceSet.registerDynamicEPackages(ecoreLocalPath);
resourceSet.registerXMIResourceFactories("*");
EObject root = resourceSet.getResource(ecoreLocalPath).getContents().get(0);
EPackage epModel = resourceSet.getPackageRegistry().getEPackage( ((EPackage)root).getNsURI());
Module module = resourceSet.getModule(henshinLocalPath, false);
EGraph graph = new EGraphImpl();
graph.addTree(epModel);
// Initialize the interpreter:
Engine engine = new EngineImpl();
Unit unit = module.getUnit("mainUnit");
UnitApplication unitApp = new UnitApplicationImpl(engine, graph, unit, null);
// Execute the transformation unit:
InterpreterUtil.executeOrDie(unitApp);
Module result = (Module) unitApp.getResultParameterValue("moduleParam");
// Save the result?
if (saveResult) {
resourceSet.saveEObject(result, generatedHenshinfilesLocalPath);
}
}
Thanks in advance,
Nebras Nassar
M. Sc. Nebras Nassar
Philipps-Universität Marburg
Fachbereich Mathematik und Informatik
Hans-Meerwein-Str. – Raum 05D04
35032 Marburg
Phone: 06421-2821513
Email: nassarn AT informatik.uni-marburg.de