NMFCode / NMF

This repository contains the entire code for the .NET Modeling Framework
BSD 3-Clause "New" or "Revised" License
36 stars 15 forks source link

Issue loading model created in EMF #55

Closed FMRobbe closed 4 years ago

FMRobbe commented 4 years ago

Hi there, I have been following the tutorial in both the paper and on youtube to load a model from EMF into a C# project I'm working on. I used eclipse EMF 2019-3 to create the .ecore and model instances, and got EMF via nuget in a clean C# project. The model fails to load depending on which parts of it are instantiated. The model has a ProductLibrary with [0...*] products, and within each products workpiecetypes which are referenced by productsegments.

I found that EMF and NMF save the references in a different way.

EMF saved it like this:

<product:ProductLibrary ...>
  <products ID="C40">
    <productsegments ID="segment" workpieceOut="//@products[ID='C40']/@workpiecetypes.0"/>
    <workpiecetypes ID="workpiece"/>
  </products>
</product:ProductLibrary>

NMF like this:

<product:ProductLibrary ...>
  <products ID="C40">
    <productsegments ID="segment" workpieceOut="C40/@workpiecetypes.0" />
    <workpiecetypes ID="workpiece" />
  </products>
</product:ProductLibrary>

Is there a way for me to load the model created in EMF in NMF without an aditional step to translate between the reference styles?

georghinkel commented 4 years ago

NMF has a different way of handling identifiers. To be honest, there I did not find a good specification of the format that EMF uses beyond XMI and so far, have only supported what I have seen. This does not include this XPath-like structure.

georghinkel commented 4 years ago

Please check if https://github.com/NMFCode/NMF/commit/195fc1f6d7b8f39398c4f91ad11f35d29f63547f solves your issue. If not, I would be thankful if you could provide a minimal example.

FMRobbe commented 4 years ago

The latest version does not seem to fix the issue (I used 2.0.154 from nuget). I created a small example project. If I find the time I'll also try to figure out how to write a test for it. NMF_bug_minimal_example.zip

georghinkel commented 4 years ago

Sorry, I forgot the question marks in the regular expression. Should be fixed now. I also turned the metamodel into a unit test that makes sure that the cross-reference is correctly resolved.