Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » Acceleo and Xtext metamodel(Getting errors when want to use metamodel created by Xtext)
Acceleo and Xtext metamodel [message #1611853] Wed, 11 February 2015 16:58 Go to next message
duke vah is currently offline duke vahFriend
Messages: 33
Registered: December 2013
Member
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 #1611910 is a reply to message #1611853] Wed, 11 February 2015 17:48 Go to previous messageGo to next message
duke vah is currently offline duke vahFriend
Messages: 33
Registered: December 2013
Member
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 #1612235 is a reply to message #1611910] Wed, 11 February 2015 22:49 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 5586
Registered: July 2009
Senior Member
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 Go to previous messageGo to next message
duke vah is currently offline duke vahFriend
Messages: 33
Registered: December 2013
Member
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 Go to previous messageGo to next message
duke vah is currently offline duke vahFriend
Messages: 33
Registered: December 2013
Member
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 #1730705 is a reply to message #1612323] Wed, 27 April 2016 19:17 Go to previous messageGo to next message
nes ab is currently offline nes abFriend
Messages: 7
Registered: March 2016
Junior Member
Hi
please whate is the type of "TGRLStandaloneSetup"
thank you
Re: Acceleo and Xtext metamodel [message #1730706 is a reply to message #1730705] Wed, 27 April 2016 19:51 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 11629
Registered: July 2009
Senior Member
TGRLStandaloneSetup is generated by xtext. its default name is MyDslStandaloneSetup.

Need professional support for Xtext, Xpand, EMF?
Go to: http://xtext.itemis.com
Twitter : @chrdietrich
Blog : christiandietrich.wordpress.com
Re: Acceleo and Xtext metamodel [message #1730708 is a reply to message #1730706] Wed, 27 April 2016 21:04 Go to previous message
nes ab is currently offline nes abFriend
Messages: 7
Registered: March 2016
Junior Member
Thank you so much your idea help me
Thanks
Previous Topic:acceleo launching
Next Topic:Cannot Access Stereotypes
Goto Forum:
  


Current Time: Wed Jan 24 12:02:37 GMT 2018

Powered by FUDForum. Page generated in 0.01688 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software