3

Is there a way to generate from a ECore model code that is not Java? I have a meta-model that represent a html layout (forms, inputs, buttons) and I want to generate the html.

How can I do this? What other tools must I use? A link to a tutorial would be perfect because i haven't found one yet.

skaffman
  • 398,947
  • 96
  • 818
  • 769
AdrianS
  • 1,980
  • 7
  • 33
  • 51
  • Have you solved this problem? I have the similar problem and have written about it here: https://www.eclipse.org/forums/index.php/t/687002/ – Mind Mixer Apr 07 '14 at 16:00

2 Answers2

3

I think the best way to approach this is to create your meta model in Ecore as you already have done, then generate the Java code and probably also an EMF tree editor to create models. (Note that the Java code for the meta model needs to be generated so that the resulting models can be traversed and interpreted by the EMF tooling. So you don't generate other languages directly from the Ecore -- that is done in a separate step as described below),

Next, use XPand -- the Xtext templating language -- to generate HTML code from your models. Here is a blog post that explains how to do create an HTML form from a model:

http://www.peterfriese.de/getting-started-with-code-generation-with-xpand/

You can likely skip the step "creating the metamodel" and just use the one you have created already. This article is a good introduction to XPand, which is a very powerful language and which some beleive is better than Jet.

awynne
  • 427
  • 5
  • 12
0

I think the answer depends on whether your generated stuff should be generated along with the current classes or in a completely different process.

If it is a different process, look at the Xpands answer - EMF generate non-Java Code

Otherwise look at JET as this is used to generate the rets of the artifacts from ecore. It is not pretty - Java within Java will never be readable - but it is pretty easy to add to the existing generate from .genmodel process.

Community
  • 1
  • 1
Tonny Madsen
  • 12,628
  • 4
  • 31
  • 70