2017-04-17 93 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