模式更改后重新生成ecore

发布于 2024-08-01 12:46:32 字数 135 浏览 2 评论 0原文

我在 xsd 文件中有一个架构。 偶尔会创建新版本的架构,我需要更新我的 .ecore (和 .genmodel)。 如何更新它们,而不删除它们并重新生成它们。 我对ecore做了一些手动修改,我想保留这些修改。

我愿意。

I have a schema in xsd file. once in a while a new version of the schema is created, and I need to update my .ecore (and .genmodel).
How do I update them, without deleting them and re-generate them. I have made some manual modification to the ecore, and i want to keep this modifications.

Ido.

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

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

发布评论

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

评论(4

ぃ弥猫深巷。 2024-08-08 12:46:32

您可以使用上下文菜单选项重新生成。 保留您的修改:

  • 如果有一个方法的名称中添加了“Gen”(例如,除了 setWhatever 之外还有 setWhateverGen),将为“Gen”方法生成新代码。 因此,请保留“Gen”方法,以便可以覆盖它,然后从可以修改的非 Gen 方法中调用它。
  • 所有生成的方法都用@ generated注释。 如果您添加“NOT” - @ generated NOT - 它不会被覆盖。

所有其他内容应合并。 继续实验——这就是版本控制的用途......

You can regenerate using the context menu options. To preserve your modifications:

  • If there is a method that has "Gen" added to the name -- e.g. setWhateverGen in addition to setWhatever -- new code will be generated to the "Gen" method. So leave the "Gen" method alone so that it can be overwritten, and then call it from the non-Gen method, which you can modify.
  • All the generated methods are annotated with @generated. If you add "NOT" -- @generated NOT -- it will not be overwritten.

All other content should be merged. Go ahead and experiment -- that's what version control is for....

酸甜透明夹心 2024-08-08 12:46:32

对 *.genmodel 使用“重新加载...”操作,根据新版本的 *.xsd 更新 *.ecore。

Use the Reload... action on the *.genmodel to update the *.ecore based on the new version of the *.xsd.

静赏你的温柔 2024-08-08 12:46:32

并且不要直接更改 .ecore。 在架构中使用ecore: 注释。 http://www.eclipse.org/modeling/emf/docs/概述/XMLSchemaToEcoreMapping.pdf

And don't change the .ecore directly. Using ecore: annotations in the schema. http://www.eclipse.org/modeling/emf/docs/overviews/XMLSchemaToEcoreMapping.pdf

风追烟花雨 2024-08-08 12:46:32

我从来没有尝试过这个,但是 XSD FAQ 说:

JAXB 生成一个简单的 Java API
一个 XML 模式,它使用
本质上是黑盒设计。 电磁场
给定 XML 生成 Ecore 模型
架构,然后使用基于模板
发电机技术来产生
丰富的Java API(手写的
质量)。 XML 模式到 Ecore
转换可以定制,
用于生成 Java 的模板
API 可以定制,并且生成的结果
Java API 可以定制。
生成器支持合并
再生,以便它能够保存
您手写的更改。
在其他中
换句话说,EMF 更丰富、更多
灵活,支持更广泛
XML 模式的子集(特别是在
2.0,将支持通配符和混合内容)。

如果我是你,我会尝试一些实验来看看这个过程的效果如何,以及实际的限制是什么。

I've never tried this, but the XSD FAQ says this:

JAXB produces a simple Java API given
an XML Schema and it does so using
essentially a black box design. EMF
produces an Ecore model given an XML
Schema and then uses template-based
generator technology to generate a
rich Java API (of hand written
quality). The XML Schema to Ecore
conversion can be tailored, the
templates used to generate the Java
API can be tailored, and the resulting
Java API can be tailored. The
generator supports merging
regeneration so that it will preserve
your hand written changes.
In other
words, EMF is far richer and more
flexible, and supports a broader
subset of XML Schema (especially in
2.0, where wildcards and mixed content will be supported).

If I were you, I'd try some experiments to see how well this process works, and what the practical limitations are.

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