Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » [Xtend] M2T transformation examples
[Xtend] M2T transformation examples [message #1840846] Mon, 26 April 2021 14:51 Go to next message
Tomas Wall is currently offline Tomas WallFriend
Messages: 44
Registered: April 2021
Member
Hi,

I am planning to use Xtend to write model to text transformations. I have not been able to find examples of that to get started. Do you have any information about possible, guides, tutorials, youtube videos that can helo me get started for M2T transformations with Xtend?

Thanks, Tomas!
Re: [Xtend] M2T transformation examples [message #1840851 is a reply to message #1840846] Mon, 26 April 2021 18:27 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7222
Registered: July 2009
Senior Member
Hi

The M2T capabilities inherited from Xpand are something of a secret; in the documentation look for "String Templates".

When Xtend first became available there was talk that it was leading the way on to Java 7 after Java had 'frozen'. Now Java is moving at a disquieting rate and has left much of Xtend behind, so that IMHO String Templates are Xtend's main/sole virtue. Consequently I write many of my Xtend templates as an xxxXtend.java containing the string templates and inheritaing from xxx.java that contains normal Java functionality. Sadly the Xtend tooling is inferior to JDT, so by using mostly Java most of Xtend's limitations are avoided.

You may find some examples in https://git.eclipse.org/r/plugins/gitiles/ocl/org.eclipse.ocl/+/refs/heads/master/examples/org.eclipse.ocl.examples.build/src/org/eclipse/ocl/examples/build/xtend/

GenerateGrammarXtend / GenerateGrammar is the most self-contained.

https://git.eclipse.org/r/plugins/gitiles/ocl/org.eclipse.ocl/+/refs/heads/master/plugins/org.eclipse.ocl.xtext.oclinecore/src-gen/org/eclipse/ocl/xtext/oclinecore/OCLinEcoreGrammarResource.java is the output from the OCLnEcore.xtext grammar.

You should be aware that there is some discussion about the Xtend project terminating due to lack of developer support. Since Xtend autogenerates pure Java from the Xtend files, you have an escape route should Xtend termination actually occur.

Regards

Ed Willink




Re: [Xtend] M2T transformation examples [message #1841049 is a reply to message #1840851] Sat, 01 May 2021 23:04 Go to previous messageGo to next message
Tomas Wall is currently offline Tomas WallFriend
Messages: 44
Registered: April 2021
Member
Hi Ed,

Thank you for your answer. What do you think about Xtend's capabilities for model-to-text transformations from UML profiles to an Xtext grammar? Let's take MARTE for example.

Best,
Tomas
Re: [Xtend] M2T transformation examples [message #1841052 is a reply to message #1841049] Sun, 02 May 2021 06:40 Go to previous message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7222
Registered: July 2009
Senior Member
Hi

IMHO any M2T tool is inappropriate for an M2M problem. A UML profile is a model, Xtext has an underlying model (conforms to Xtext.ecore) so you you can use an M2M and avoid all the illegal syntax problems that come from an M2T generation that is unaware of the output rules. Use the target model support to serialize to text.

You can see in [1] how Xtext can be used as the source of an M2M. Using it as the target should be no different. Caveat: Xtext uses a classpath: protocol that is not properly installed so you need to avoid multi-level Xtext grammars if you want to use the Sample Ecore Model Editor as a debug aid.:

Regards

Ed Willink

[1] https://git.eclipse.org/c/ocl/org.eclipse.ocl.git/tree/examples/org.eclipse.ocl.examples.xtext2lpg/src/org/eclipse/ocl/examples/xtext2lpg/xtext2xbnf.qvto
Previous Topic:[Acceleo] Map data type?
Next Topic:Acceleo 3 standalone with traceability
Goto Forum:
  


Current Time: Sat Jul 31 11:24:55 GMT 2021

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

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

Back to the top