Acceleo and Xtext metamodel [message #1611853] |
Wed, 11 February 2015 16:58  |
Eclipse User |
|
|
|
Hi,
I have been trying to generate code for my own metamodel created in Xtext by Acceleo. However, I receive the following errors.
Quote:
Exception in thread "main" org.eclipse.emf.ecore.resource.impl.ResourceSetImpl$1DiagnosticWrappedException: org.xml.sax.SAXParseExceptionpublicId: file:/C:/workspaces/URN/org.xtext.tgrl.samples/pkg01/p001.xgrl; systemId: file:/C:/workspaces/URN/org.xtext.tgrl.samples/pkg01/p001.xgrl; lineNumber: 1; columnNumber: 1; Content is not allowed in prolog.
at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.handleDemandLoadException(ResourceSetImpl.java:319)
at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLoadHelper(ResourceSetImpl.java:278)
at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResource(ResourceSetImpl.java:406)
at org.eclipse.acceleo.common.utils.ModelUtils.load(ModelUtils.java:391)
at org.eclipse.acceleo.common.utils.ModelUtils.load(ModelUtils.java:356)
at org.eclipse.acceleo.engine.service.AbstractAcceleoGenerator.initialize(AbstractAcceleoGenerator.java:475)
at org.eclipse.acceleo.module.tgrl.main.Generate.<init>(Generate.java:90)
at org.eclipse.acceleo.module.tgrl.main.Generate.main(Generate.java:144)
Caused by: org.xml.sax.SAXParseExceptionpublicId: file:/C:/workspaces/URN/org.xtext.tgrl.samples/pkg01/p001.xgrl; systemId: file:/C:/workspaces/URN/org.xtext.tgrl.samples/pkg01/p001.xgrl; lineNumber: 1; columnNumber: 1; Content is not allowed in prolog.
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:203)
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(ErrorHandlerWrapper.java:177)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:441)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:368)
at com.sun.org.apache.xerces.internal.impl.XMLScanner.reportFatalError(XMLScanner.java:1436)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.next(XMLDocumentScannerImpl.java:999)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:606)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:510)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:848)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:777)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:141)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1213)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:649)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl.parse(SAXParserImpl.java:333)
at org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(XMLLoadImpl.java:175)
at org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.doLoad(XMLResourceImpl.java:261)
at org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(ResourceImpl.java:1518)
at org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(ResourceImpl.java:1297)
at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLoad(ResourceSetImpl.java:259)
at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLoadHelper(ResourceSetImpl.java:274)
... 6 more
The steps I have followed:
- developed my xText language and installed it on my Eclipse. Now, I can work with my plugin. I can also see AST in the outline section.
- I created a small Acceleo project which creates a file without any consideration. When I run "generate.mtl" file inside of eclipse I receive the above error.
The Acceleo file is like this:
Quote:
[comment encoding = UTF-8 /]
[**
* The documentation of the module generate.
*/]
[module generate('http://www.xtext.org/grl/tgrl/TGRL')]
[**
* The documentation of the template generateElement.
* @param aModel
*/]
[template public generateElement(aModel : Model)]
[comment @main/]
[file ('a.txt', false, 'UTF-8')]
This is an example.
[/file]
[/template]
I am sure that the Acceleo works fine because I applied the same process on UML and it worked.
In a topic, it's said there might be no "bin" folder but I checked I have.
Any help will be appreciated.
Thanks.
|
|
|
|
Re: Acceleo and Xtext metamodel [message #1612235 is a reply to message #1611910] |
Wed, 11 February 2015 22:49   |
Eclipse User |
|
|
|
Hi
You probable need
XgrlStandaloneSetup.doSetup()
where Acceleo syas to regster your models.
Regards
Ed Willink
On 11/02/2015 17:48, duke vah wrote:
> BTW, the model is not an XMI format. It's a text as we expect from xtext.
> For example,Quote:
>> grl {
>> actor A{
>> }
>> actor B{
>> }
>> }
>
|
|
|
Re: Acceleo and Xtext metamodel [message #1612279 is a reply to message #1612235] |
Wed, 11 February 2015 23:28   |
Eclipse User |
|
|
|
Hi,
Could you be more specific.
Is it inside the generate.java?
Inside this file there are two registerPackages and registerResourceFactories files used for standalone use.
I'm running inside the eclipse and there is no another section that I can put doSetup().
I would be grateful if you could say exactly where I must put it.
Thanks.
|
|
|
Re: Acceleo and Xtext metamodel [message #1612323 is a reply to message #1612279] |
Thu, 12 February 2015 00:07   |
Eclipse User |
|
|
|
Hi,
I solved the issue. Thank you.
I write here the solution for the future reference.
What is needed is that just call doSetup() in two places
Quote:
public Generate(URI modelURI, File targetFolder,
List<? extends Object> arguments) throws IOException {
TGRLStandaloneSetup.doSetup();
initialize(modelURI, targetFolder, arguments);
}
Quote:
public Generate(EObject model, File targetFolder,
List<? extends Object> arguments) throws IOException {
TGRLStandaloneSetup.doSetup();
initialize(model, targetFolder, arguments);
}
Thanks.
|
|
|
|
|
|
|
Re: Acceleo and Xtext metamodel [message #1782046 is a reply to message #1612323] |
Fri, 16 February 2018 12:38   |
Eclipse User |
|
|
|
Hi Duke,
I am encountering the exact same problem with a TGRL project.
I tried to follow your solution but I am getting an error at the doSetup() calls.
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
MyDslStandaloneSetup cannot be resolved
MyDslStandaloneSetup cannot be resolved
at org.eclipse.acceleo.module.GRL2Text.main.Generate.<init>(Generate.java:90)
at org.eclipse.acceleo.module.GRL2Text.main.Generate.main(Generate.java:146)
I have also tried to use the other object TGRLStandaloneSetup.doSetup(). But it is showing the same error.
Can you please tell me which object to use and where to find it in my system directory?
Thanks and Regards,
Novarun.
|
|
|
|
Powered by
FUDForum. Page generated in 0.04121 seconds