Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » XText model to XMI model
XText model to XMI model [message #1835186] Thu, 26 November 2020 15:55 Go to next message
John Henbergs is currently offline John HenbergsFriend
Messages: 239
Registered: October 2020
Senior Member
Hi all,

I am trying to get around Epsilon ETL and XText. I want to use the XText model to write some transformation rules, but I cannot add it to ETL. ETL, only accepts the following model types.

index.php/fa/39420/0/

Is there a way, to automatically generate one of these model types from the XText model? Or any other solution that might come to mind?

Thank you!
Re: XText model to XMI model [message #1835203 is a reply to message #1835186] Fri, 27 November 2020 05:54 Go to previous messageGo to next message
Tamas Miklossy is currently offline Tamas MiklossyFriend
Messages: 157
Registered: February 2016
Senior Member
Hello John,

You can open the Xtext DSL file with the 'Sample Ecore Model Editor' using the Open With -> Other... context menu in the Package Explorer.
After that, the content of the editor can be saved as an *.xmi file using the File -> Save as Menu.

Hope that helps,
Tamás
Re: XText model to XMI model [message #1835235 is a reply to message #1835203] Fri, 27 November 2020 14:48 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

Yes. Open with Sample Ecore Model Editor worked (10 years ago), but it broke quite sometime ago and I still have a Bugzilla open [1]. The problem is that Xtext uses the classpath: scheme that is handled by irregular code in Xtext's non-standard ResourceSet rather than by a classpath: scheme protocol registration. Consequently tools that do not provide careful initialization fail when using standard functionality..

[1] https://bugs.eclipse.org/bugs/show_bug.cgi?id=446073

Regards

Ed Willink
Re: XText model to XMI model [message #1849318 is a reply to message #1835186] Wed, 12 January 2022 17:33 Go to previous messageGo to next message
Campbell McCausland is currently offline Campbell McCauslandFriend
Messages: 3
Registered: May 2020
Junior Member

I'm running into this issue while trying to run some Epsilon transforms on an Xtext source file. I would like to try the fix Ed proposed in his Bugzilla issue.

Not sure where or how to apply it though, my Eclipse development skills have become a little rusty over the last decade ;-).

The solution uri handler class indicates that it should be installed using an mwe2 script. I'm not clear on which one or how to arrange for it to be installed permanently in my eclipse instance. I'd have thought building a small plugin would have been the way to achieve that.

So Ed, if you get a moment I'd sure appreciate some pointers on how to get your handler class installed.
Re: XText model to XMI model [message #1849338 is a reply to message #1849318] Thu, 13 January 2022 06:08 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

I suspect that you are solving a non-problem. Epsilon has an impressive breadth of capability. I find it difficult to believe that it cannot load what is really a standard EMF resource with a fancy registered loader. Raise a Bugzilla. You probably just need to re-use one of the existing models; perhaps "EMF Model" or "M0 EMF Model" with unchnaged file name.

In the absence of an Xtext or Epsilon fix, you can write a small Java EMF program to load the Xtext Resource migrate its Resource.getContents() to an XMIResourceImp and save it.

Regards

Ed Willink
Re: XText model to XMI model [message #1849345 is a reply to message #1849338] Thu, 13 January 2022 10:25 Go to previous messageGo to next message
Campbell McCausland is currently offline Campbell McCauslandFriend
Messages: 3
Registered: May 2020
Junior Member
Hi Ed and thank you for the reply.

There are indeed many other ways to get the data into Epsilon, and addiing a generator to create an XMI resource alongside the human readable source is straightforward. However, that significantly dilutes the benefit of providing a human readable input to the tool flow. We don't really want intermediate files lying around if there is an alternative.

I should perhaps have said at the outset that I was already in contact with the Epsilon team and they have said that they rely on this mechanism to provide the automatic conversion from DSL to in-memory EMF resource, and indeed it works for 'end user' DSL's just not for Xtext format files. Epsilon uses the same mechanism described here for the EMF sample reflective editor:

https://wiki.eclipse.org/Xtext/FAQ#How_can_I_load_my_model_in_the_EMF_reflective_model_editor.C2.A0.3F

Please can you explain how best to introduce your handler? Creating a small Eclipse plugin to declare and register the handler is one solution I know how to implement, but the Bugzilla you linked implied a different mwe2 based solution. I am hoping to understand why. If a plugin is an acceptable solution and has no drawbacks, I'll get on with building it.

Many thanks,

Campbell
Re: XText model to XMI model [message #1849346 is a reply to message #1849345] Thu, 13 January 2022 11:18 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

If it works for DSL files, it should work for Xtext, because Xtext is 'just' a DSL

I only suggested a custom program as a workaround. Obviously it's an undesirable pain.

I strongly suggest debugging the Xtext load problem, using the divergence in behaviour between an ordinary DSL and Xtext as the detection for where the bug lies.

A possible hazard could lie in Xtext's use of a custom ResourceSet. If Epsilon also uses a custom ResourceSet these may not play well together.

Regards

Ed Willink
Re: XText model to XMI model [message #1849354 is a reply to message #1849346] Thu, 13 January 2022 13:44 Go to previous messageGo to next message
Dimitris Kolovos is currently offline Dimitris KolovosFriend
Messages: 2163
Registered: July 2009
Location: York, UK
Senior Member

Thanks for the insights Ed!

Campbell, John: Until the bug that Ed reported is fixed, I've thrown together a custom Epsilon driver for Xtext grammars that works around it in https://github.com/epsilonlabs/emc-xtext

Cheers,
Dimitris
Re: XText model to XMI model [message #1849359 is a reply to message #1849354] Thu, 13 January 2022 15:52 Go to previous message
Campbell McCausland is currently offline Campbell McCauslandFriend
Messages: 3
Registered: May 2020
Junior Member
Many thanks Dimitris!

Your plugin solves the problem by adding an explicit Xtext model type to Epsilon.

I found I needed to manually add the Xtext meta model URI in the Epsilon Metamodels box, but after that it Just Worked.

Kudos!

[Updated on: Thu, 13 January 2022 15:59]

Report message to a moderator

Previous Topic:Xtext with Java as code generator
Next Topic:Partial instance conversion between EMF<->Xtext
Goto Forum:
  


Current Time: Fri Apr 26 02:39:39 GMT 2024

Powered by FUDForum. Page generated in 0.03959 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top