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

Deserialization from unqualified xml #26

Closed ChrisH07 closed 6 years ago

ChrisH07 commented 6 years ago

I'm trying to deserialize from an xml document that is unqualified (Simulink diagram) and I get an exception inside GetTypeInfo stating that the type can't be found in namespace "". To create my model I took an existing Ecore model and used Ecore2Code to create the nmeta model. Since the Ecore model was generated from an schema file I had to fix the XMLType references (same as #23). I could not deserialize a model file since it was expecting fully qualified elements, so I modified the meta model by setting Prefix="" in the root Namespace element. I could then serialize manually created models with some added artifacts, but get an exception when deserializing real models. Stepping in the debugger shows the model elements are added to typesByQualifier with a key corresponding to the Uri. If I also set Uri="" then nothing is added to typesByQualifier and I get the same exception. How do I work with a model whose elements are unqualified?

georghinkel commented 6 years ago

Hi Chris,

to be honest, I never really thought about unqualified elements but the use case of Simulink models is obvious. I will make some experiments and come back to you.

Best,

Georg

georghinkel commented 6 years ago

OK, so there is definitely a bug. The problem is that a namespace in NMF has two URIs, one that identifies the element globally for NMF and another one that is used for XML serialization. Usually, they are the same, but it seems that there are some null checks that take the wrong URI into account. Therefore, I am marking this as a bug. I will see what I can do. Hopefully, I can fix it by today or at least by the end of this week.

ChrisH07 commented 6 years ago

Hi Georg,

Thanks for looking into this. Please let me know if I can do anything to help.

Chris

georghinkel commented 6 years ago

Hi Chris,

sorry, I was distracted from testing whether my bugfix actually solves your problem. Only now, I was able to verify that it works and yes it does, since commit 1e03db3541a5c89dab87c331149d046535460a52. All you have to do is to pass an additional model uri as a parameter (using -u or --model-uri). This is the URI that you should specify in the metadata attribute and this is also the URI where you find the metamodel in the repositories.

Best,

Georg

ChrisH07 commented 6 years ago

Hi Georg,

I've verified your changed resolves this issue.

Thank you,

Chris