EMF ecore 和 xsd 不同步,如何解决?

发布于 2024-08-03 10:50:20 字数 985 浏览 1 评论 0原文

我的应用程序使用基于 xsd 的模型,该模型在生成 java 类之前已转换为 ecore。 我的一位团队成员修改了以前版本中的 .ecore 元模型,这是过去生成的一个属性。他修改了属性名称,但没有修改指定用于 xml 持久性的元素名称的扩展元数据。

<eStructuralFeatures xsi:type="ecore:EReference" name="javaDocsAndUserApi" upperBound="-1"
    eType="#//JavaDocsAndUserApi" containment="true" resolveProxies="false">
  <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
    <details key="kind" value="element"/>
    <details key="name" value="docsAndUserApi"/>
  </eAnnotations>
</eStructuralFeatures>

所以我们有一个属性名称为 javaDocsAndUserApi 和名为 docsAndUserApi 的持久元素,当然,如果我创建,则将 xsd 中的属性更改为 javaDocsAndUserApi< /strong>,ecore 转换也会生成一个元数据名称 javaDocsAndUserApi,这将破坏与之前持久化模型的兼容性。

我查看了 xsd 创作指南,找到了一个 ecore:som_attribute,它允许我指定在 xsd 中使用哪个键,以在 xsd 到 ecore 转换期间强制将元数据命名为 docsAndUserApi 但没有找到任何东西。 有人有想法可以帮助我吗?

谢谢。

My application is using a model base on an xsd that have been converted to an ecore before generation of the java classes.
One of my team member modified the .ecore metamodel in a previous version ,one attribute that used to be generated. He modified the attribute name but not the Extended MetaData specifying the element name used for xml persistance.

<eStructuralFeatures xsi:type="ecore:EReference" name="javaDocsAndUserApi" upperBound="-1"
    eType="#//JavaDocsAndUserApi" containment="true" resolveProxies="false">
  <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
    <details key="kind" value="element"/>
    <details key="name" value="docsAndUserApi"/>
  </eAnnotations>
</eStructuralFeatures>

so we have an attribute name which is javaDocsAndUserApi and the persisted element named docsAndUserApi, and of course if I create change the attribute in the xsd to be named javaDocsAndUserApi, the ecore transformation will generate a metadata name javaDocsAndUserApi as well, which will break compatibility with previously persisted models.

I have looked at xsd authoring guide to find an ecore:som_attribute that would allow me to specify which key to use in the xsd to force the metadata to be named docsAndUserApi during the xsd to ecore transformation but did not find anything.
Does anybody have an idea to help me?

Thank you.

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

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

发布评论

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

评论(1

瑾兮 2024-08-10 10:50:20

毕竟,处理不断发展的(元)模型并不容易。它基本上归结为将数据从一种格式(符合一种 Ecore 模型)迁移到另一种格式(符合另一种 Ecore 模型)。

您可以应用模型转换技术,例如 ATLAMW。这允许您连接(编织)两个 Ecore(元)模型(m1 和 m2),并自动生成将数据从格式 m1 转换为格式 m2 的代码,反之亦然。 (有关此主题的一些非常有趣的研究论文,请参阅此处。)

务实的方法可能是使用 EMF 手动实现模型转换。由于模型之间的更改很简单,因此实现起来应该不会太难。

Dealing with evolving (meta-) models is not easy after all. It's basically comes down to migrating data from one format (conforming to one Ecore model) into another (conforming to another Ecore model).

You can apply model transformation techniques like ATL and AMW. This allows you to connect (weave) two Ecore (meta-) models (m1 and m2) and automatically generate code that transforms data from format m1 to format m2 and vice versa. (See here for some very interesting research papers on this subject.)

A pragmatic approach might be to manually implement the model transformation using EMF. Since the changes between your models are simple, this shouldn't be too hard to implement.

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