简体   繁体   English

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

[英]EMF ecore and xsd out of sync, how to resolve?

My application is using a model base on an xsd that have been converted to an ecore before generation of the java classes. 我的应用程序使用基于xsd的模型,该模型在生成Java类之前已转换为ecore。 One of my team member modified the .ecore metamodel in a previous version ,one attribute that used to be generated. 我的一个团队成员在以前的版本中修改了.ecore元模型,该属性曾经生成过。 He modified the attribute name but not the Extended MetaData specifying the element name used for xml persistance. 他修改了属性名称,但未修改Extended MetaData,而是指定了用于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>

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. 因此,我们有一个名为javaDocsAndUserApi的属性名称和一个名为docsAndUserApi的持久化元素,当然,如果我在xsd中创建将属性更改为javaDocsAndUserApi ,则ecore转换还将生成一个元数据名称javaDocsAndUserApi ,这将破坏与以前持久的模型。

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. 我查看了xsd编写指南,找到了一个ecore:som_attribute,它可以让我指定在xsd中使用哪个键来强制在xsd到ecore转换期间将元数据命名为docsAndUserApi ,但没有找到任何东西。 Does anybody have an idea to help me? 有人有帮助我的想法吗?

Thank you. 谢谢。

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). 基本上,归结为将数据从一种格式(符合一种Ecore模型)迁移到另一种格式(符合另一种Ecore模型)。

You can apply model transformation techniques like ATL and AMW . 您可以应用模型转换技术,例如ATLAMW 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. 这使您可以连接(编织)两个Ecore(元)模型(m1和m2)并自动生成将数据从格式m1转换为格式m2,反之亦然的代码。 (See here for some very interesting research papers on this subject.) (有关此主题的一些非常有趣的研究论文,请参见此处 。)

A pragmatic approach might be to manually implement the model transformation using EMF. 一种实用的方法可能是使用EMF手动实施模型转换。 Since the changes between your models are simple, this shouldn't be too hard to implement. 由于模型之间的更改很简单,因此实现起来应该不太困难。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM