Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » M2T with Xtext2 and Xtend2
M2T with Xtext2 and Xtend2 [message #1052814] Tue, 30 April 2013 15:16 Go to next message
Rene Grellert is currently offline Rene GrellertFriend
Messages: 2
Registered: April 2013
Location: Germany
Junior Member
Hi there,

I'm a bit confused about how Xtext2 and Xtend2 could solve my M2T-problem.
I've worked on a project using Open Architecture Ware ( oAW, or MWE) and the three languages Xpand, Check and Xtend before. My question is, how can the following steps be achived using Xtend2 and Xtext2 like we did with oAW before:
We've written a workflow for parsing a text document and generating code for different platforms. We had an own parser for parsing the textfile and instanciating a respecitve ecore model. Xtend was used then to transform this model into another one and several Chk.-files ensured the validity of the model. Then a Xpand-Template File was triggert with the newly created model generating the text-output.

So, now I have a project where I want to have an equivalent workflow but with Xtend2 and Xtext2 as those seem to be the new state of the art. This is what i've learnt so far:
The Modeling Workflow Engine (MWE) as it was called firstly, is now a part of Xtext2 having the name MWE2. It is a DSL written in Xtext that lets you design workflows pretty easily. Xtext2 is a language for writing own DSLs with full editor-integration. Xtend2 is yet another language based on Xtext2 and tries to fix some of Java's weaknesses by enabling type inference and other features. Its template expressions has the same power of the previous Xpand language.
Ok, now I wonder, if I simply want to transform an (ecore) model into text after performing some parsing and M2M magic, why would I want to write an own DSL inclosing a very complex grammar and stuff. All I need is to create an instance of the let's say "final" model and feed the Xtend2-Generator with it. Is it even sensible to use Xtext2 for this approach? And if not, why is MWE2 a part of Xtext2 and not of Xtend2?

I really hope, I could point out some of my problems here. I guess what makes me confused is that I'm trying to map the previously used approach with MWE on the newly created framework. But I liked it a lot because the way of designing a workflow and performing transformations inside this workflow on manually designed models was a perfect way of ensuring transparency and maintanability.

Grettings, René
Re: M2T with Xtext2 and Xtend2 [message #1053487 is a reply to message #1052814] Mon, 06 May 2013 08:54 Go to previous messageGo to next message
Karsten Thoms is currently offline Karsten ThomsFriend
Messages: 762
Registered: July 2009
Location: Dortmund, Germany
Senior Member

Quite a lot of confusion Smile I doubt I can solve it with a few sentences.

Xtend2 is written with Xtext, but it does not mean that you need to write a DSL with Xtext in order to use Xtend2 to generate code. Xtend2 compiles to Java, so everything is like you would do writing a code generator just with Java, only much easier.

However, when it comes to integrate an Xtend2 based generator into a workflow, there is first-class support only for Xtext based models, since Xtext provides a standard workflow component "GeneratorComponent" that uses the IGenerator implementation as generator root. The infrastructure for code generators becomes less when dealing with non-Xtext models. However, all you need to do is to write a custom worflow component, derived from AbstractWorkflowComponent2, create an instance of your Xtend class and invoke it. I am expecting more support for this in the future, when Xtend's new Active Annotations become mature.

Similar to M2M transformations. They can be written with Xtend2 like before with Xtend1, but invocation requires a custom component.

MWE2 is part of the Xtext project, since it is a language that is is developed with Xtext and to some degree is an example language. It has nothing to do with Xtend2, and actually existed way before Xtend2 was developed. The old-style .mwe/.oaw workflows with XML syntax are still valid, the MWE SDK provides support for that (MWE is part of EMFT).

Validating a model is another thing which has nothing to do with Xtend2. Again, Xtext based models have more support on validating models, since Xtext's MWE Reader component validates models while reading, by using classes with @Check annotations for validation. For non-Xtext models this has to be done otherwise, e.g. by still using the old Check language.

Hope this solves some of the confusion, and not that it just becomes more.

Regards,
~Karsten


Need professional support for Xtext, EMF, Eclipse IDE?
Go to: http://devhub.karakun.com
Twitter : @kthoms
Blog : www.karsten-thoms.de
Re: M2T with Xtext2 and Xtend2 [message #1053783 is a reply to message #1053487] Tue, 07 May 2013 14:56 Go to previous message
Rene Grellert is currently offline Rene GrellertFriend
Messages: 2
Registered: April 2013
Location: Germany
Junior Member
Hi Karsten,

thanks a lot! You really solved a lot of problems I had to understand the overall framework.
As I am going to need a parser (for XML documents by the way) an idea would be to write an Xtext grammar for parsing those files and generating an instance of an ecore model. Do you think this is a convenient way or is it better to use a separate Framework like JaxB doing the parsing and manually instanciating the ecore model. In my oppinion the first approach is more consequent but might be less maintainable.

Yet there's another general question about designing Xtext-based models. Assuming I want to perform M2M-Transformation with Xtext I dont understand how the resulting model should be designed in a Xtext-grammar. If I got this right, the grammar defines how a textual input will be transformed into an ecore model instance. Performing M2MT shouldn't result in a textuel output but in an in-memory representation of the resulting model. Therefore I woun't need a grammer and parser but a manually designed ecore model, will I?
I am asking this because I am wondering why I have to write different custom components when the desribed scenario should be a basic area of application for M2T projects...

Kind regards,
René
Previous Topic:[Acceleo] How to get a default value of EnumerationLiteral attribute and how to get a target name of
Next Topic:[Acceleo] How to iterate through the global UML model from inside a template
Goto Forum:
  


Current Time: Thu Apr 25 11:56:55 GMT 2024

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

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

Back to the top