EMF 生成非 Java 代码

发布于 2024-10-09 20:44:58 字数 124 浏览 0 评论 0原文

有没有办法从 ECore 模型代码生成非 Java 代码?我有一个代表 html 布局(表单、输入、按钮)的元模型,我想生成 html。

我该怎么做?我还必须使用哪些其他工具? 教程的链接将是完美的,因为我还没有找到。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

不知在何时 2024-10-16 20:44:58

我认为解决这个问题的最佳方法是像您已经完成的那样在 Ecore 中创建元模型,然后生成 Java 代码,可能还需要一个 EMF 树编辑器来创建模型。 (请注意,需要生成元模型的 Java 代码,以便 EMF 工具可以遍历和解释生成的模型。因此,您不需要直接从 Ecore 生成其他语言——这是在单独的步骤中完成的如下所述),

接下来,使用 XPand(Xtext 模板语言)从模型生成 HTML 代码。以下博客文章解释了如何从模型创建 HTML 表单:

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

您可以跳过“创建元模型”这一步骤,而只使用您拥有的元模型已经创建了。本文很好地介绍了 XPand,这是一种非常强大的语言,有些人认为它比 Jet 更好。

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.

如果没结果 2024-10-16 20:44:58

我认为答案取决于您生成的内容是否应该与当前类一起生成,或者在完全不同的过程中生成。

如果是不同的进程,请查看 Xpands 答案 - EMF 生成非 Java代码

否则请查看 JET,因为它用于从 ecore 生成工件的 ret。它并不漂亮——Java 中的 Java 永远不可读——但是很容易添加到现有的从 .genmodel 生成过程中。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文