2017-04-17 97 views
0

首先,我是新的Acceleo和eclipse的建模功能。我想要做的只是创建一个简单的测试文件。所以对于初学者来说,我创建了一个主模块:Acceleo:代无法生成任何文件

comment encoding = UTF-8 /] 
[module generate('file:/C:/Users/maria/Documents/workspace/org.eclipse.acceleo.module.m2tTransformation/model/PSMMetamodel.ecore')] 

[template public generateElement(aServicePSM : ServicePSM)] 
[comment @main/] 
[file ('test.java', false, 'UTF-8')] 
Test 
[/file] 
[/template] 

当我运行此我得到:

The generation failed to generate any file because there are no model elements that matches at least the type of the first parameter of one of your main templates. 
The problem may be caused by a problem with the registration of your metamodel, please see the method named "registerPackages" in the Java launcher of your generator. It could also come from a missing [comment @main/] in the template used as the entry point of the generation. 

另外的URI我用的是nsURI属性值我设置为元模型的根。我确定我的输入模型确实包含ServicePSM元素。 我在做什么错?

在此先感谢。

回答

0

这个问题会在两种情况下

  1. 出现您没有正确类型的元素在你的模型
  2. 元模型不能得到解决

从你的消息,我认为我们可以安全地忽略1.因为你的模型中至少有一个ServicePSM,所以我们需要地址2.

如果你看看你的模块,你已经声明了它在元模型file:/C:/Users/maria/Documents/workspace/org.eclipse.acceleo.module.m2tTransformation/model/PSMMetamodel.ecore上生成。但是,EMF很少会使用这种URI来引用其元模型。如果使用文本编辑器(右键单击>打开方式>文本编辑器)打开实际模型,则可以查看实际用于在开始时使用“xmlns”标记引用元模型的URI。

例如,如果我打开引用OCL元素的模型,我可以看到xmlns:ocl.ecore="http://www.eclipse.org/ocl/1.1.0/Ecore"。您必须确保在模块文件中使用与您在模型文件中使用的EMF相同的URI,在这种情况下,它将是http://www.eclipse.org/ocl/1.1.0/Ecore