.xsd
将-files转换为 -files 的最佳方法是什么.ecore
?
有 Eclipse 插件吗?
.xsd
将-files转换为 -files 的最佳方法是什么.ecore
?
有 Eclipse 插件吗?
这对我有用:
要在 xsd 更改时重新验证 .ecore-File:
如果您不想每次将模式导入为 ECore 模型时都创建新的 MDT 项目,那么还有另一种方法可以做到这一点:
一个示例类。我没有清理进口。
import org.eclipse.emf.common.util.URI;
import java.io.IOException;
import java.util.Collection;
import java.util.Iterator;
import org.eclipse.emf.ecore.*;
import org.eclipse.xsd.*;
import org.eclipse.xsd.ecore.XSDEcoreBuilder;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
import org.eclipse.emf.ecore.xmi.*;
import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl;
import org.eclipse.emf.edit.ui.*;
public class Xsd2Ecore {
public static void main(String[] args) {
Xsd2Ecore x2e = new Xsd2Ecore();
x2e.go("UMLVersions/V1.0.0/UML2XMI.xsd", "UMLVersions/V1.0.0/UML2100.xmi");
}
public void go(String sourcename, String targetname) {
System.out.println("Starting");
XSDEcoreBuilder xsdEcoreBuilder = new XSDEcoreBuilder();
ResourceSet resourceSet = new ResourceSetImpl();
Collection eCorePackages = xsdEcoreBuilder.generate(URI.createFileURI(sourcename));
resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("xmi", new XMIResourceFactoryImpl());
Resource resource = resourceSet.createResource(URI.createFileURI(targetname));
for (Iterator iter = eCorePackages.iterator(); iter.hasNext();) {
EPackage element = (EPackage) iter.next();
resource.getContents().add(element);
}
try {
resource.save(null);
} catch (IOException e) {
e.printStackTrace();
}
System.out.println("Finished");
}
}
你有没有尝试过
eclipse –console –noExit –noSplash -data C:\temp\emf-ws
-application org.eclipse.xsd.ecore.importer.XSD2GenModel
它为您的 XSD 集生成 .ecore 和 .genmodel。