[help]QVTd as a parser in a standalone application [message #1015205] |
Wed, 27 February 2013 12:56  |
Eclipse User |
|
|
|
Hello,
I'm in need for a QVTr parser for my application, since QVTd uses EMF it appear to me as the best choice.
It's still my first time using a parser created in Xtext, so I tried to follow the example on Xtext FAQ (http://wiki.eclipse.org/Xtext/FAQ#How_do_I_load_my_model_in_a_standalone_Java_application.C2.A0.3F) with little success.
I dont know wich QVTd package I should be using, and what should I add to the build path...
Injector injector = new QVTrelationStandaloneSetup().createInjectorAndDoEMFRegistration();
Right now, that line is giving me the following exception:
Exception in thread "main" java.lang.NoClassDefFoundError: org/eclipse/ocl/examples/xtext/essentialocl/EssentialOCLStandaloneSetup
at org.eclipse.qvtd.xtext.qvtrelation.QVTrelationStandaloneSetupGenerated.createInjectorAndDoEMFRegistration(QVTrelationStandaloneSetupGenerated.java:20)
at TesteQVT.main(TesteQVT.java:26)
Thanks in advance,
Tiago Guimarães
|
|
|
Re: [help]QVTd as a parser in a standalone application [message #1015222 is a reply to message #1015205] |
Wed, 27 February 2013 14:47   |
Eclipse User |
|
|
|
Hi
If you're running stanalone then you should call
QVTrelationStandaloneSetup.doSetUp(), thereafter you can just use
ResourceSet.getResource() to load a *.qvtr file.
You add to the build path until you get no errors, but if you use a
Plugin project rather than a java p[roject, Eclipse does uit for you.
Regards
Ed Willink
On 27/02/2013 19:25, Tiago Guimarães wrote:
> Hello,
>
> I'm in need for a QVTr parser for my application, since QVTd uses EMF
> it appear to me as the best choice.
>
>
> It's still my first time using a parser created in Xtext, so I tried
> to follow the example on Xtext FAQ
> (http://wiki.eclipse.org/Xtext/FAQ#How_do_I_load_my_model_in_a_standalone_Java_application.C2.A0.3F)
> with little success.
>
> I dont know wich QVTd package I should be using, and what should I add
> to the build path...
>
>
> Injector injector = new
> QVTrelationStandaloneSetup().createInjectorAndDoEMFRegistration();
>
>
>
> Right now, that line is giving me the following exception:
> Exception in thread "main" java.lang.NoClassDefFoundError:
> org/eclipse/ocl/examples/xtext/essentialocl/EssentialOCLStandaloneSetup
> at
> org.eclipse.qvtd.xtext.qvtrelation.QVTrelationStandaloneSetupGenerated.createInjectorAndDoEMFRegistration(QVTrelationStandaloneSetupGenerated.java:20)
> at TesteQVT.main(TesteQVT.java:26)
>
>
> Thanks in advance,
> Tiago Guimarães
|
|
|
Re: [help]QVTd as a parser in a standalone application [message #1015956 is a reply to message #1015205] |
Mon, 04 March 2013 07:06   |
Eclipse User |
|
|
|
Hi again,
so i followed your suggestion and I used the following code:
QVTrelationStandaloneSetup.doSetup();
Injector injector = new QVTrelationStandaloneSetup().createInjectorAndDoEMFRegistration();
XtextResourceSet resourceSet = injector.getInstance(XtextResourceSet.class);
resourceSet.getResource(URI.createFileURI("AbstractToConcrete.qvtr"), true);
This worked fine, i could use resourceSet.getResources() later to get the contents...
But then i noticed, that what i wanted was not QVTrelation, but QVTrelationPivot, because we were using EMF genereted code from OMG's QVTrelations ecore, and QVTrelationPivot seemed the way to go, so i changed the code into this:
QVTrelationPivotStandaloneSetup.doSetup();
Injector injector = new QVTrelationPivotStandaloneSetup().createInjectorAndDoEMFRegistration();
XtextResourceSet resourceSet = injector.getInstance(XtextResourceSet.class);
resourceSet.getResource(URI.createFileURI("AbstractToConcrete.qvtr"), true);
by doing this i got an exception on the last line:
Exception in thread "main" org.eclipse.emf.ecore.resource.impl.ResourceSetImpl$1DiagnosticWrappedException: org.xml.sax.SAXParseExceptionpublicId: AbstractToConcrete.qvtr; systemId: file:///home/tmg/workspace/TesteQVTd/AbstractToConcrete.qvtr; lineNumber: 1; columnNumber: 1; Content is not allowed in prolog.
Thanks in advance
Tiago Guimarães
|
|
|
Re: [help]QVTd as a parser in a standalone application [message #1015964 is a reply to message #1015956] |
Mon, 04 March 2013 07:32   |
Eclipse User |
|
|
|
Hi
QVTr is a complex language with distinct (Xtext-friendly) CST and
(OMG-compliant) AST.
QVTrelationStandaloneSetup.doSetup() initializes the CST (and AST)
QVTrelationPivotStandaloneSetup.doSetup() only initialaizes the AST, so
won't do very much.
Have a look at
GIT\org.eclipse.qvtd\tests\org.eclipse.qvtd.xtext.qvtrelation.tests to
see some standalone code loading, parsing, and saving QVTr files.
You should not need to create an injector.
Regards
Ed Willink
On 04/03/2013 12:06, Tiago Guimarães wrote:
> Hi again,
>
> so i followed your suggestion and I used the following code:
>
>
> QVTrelationStandaloneSetup.doSetup();
>
> Injector injector = new
> QVTrelationStandaloneSetup().createInjectorAndDoEMFRegistration();
> XtextResourceSet resourceSet =
> injector.getInstance(XtextResourceSet.class);
>
> resourceSet.getResource(URI.createFileURI("AbstractToConcrete.qvtr"),
> true);
>
>
>
> This worked fine, i could use resourceSet.getResources() later to get
> the contents...
>
>
> But then i noticed, that what i wanted was not QVTrelation, but
> QVTrelationPivot, because we were using EMF genereted code from OMG's
> QVTrelations ecore, and QVTrelationPivot seemed the way to go, so i
> changed the code into this:
>
>
>
> QVTrelationPivotStandaloneSetup.doSetup();
>
> Injector injector = new
> QVTrelationPivotStandaloneSetup().createInjectorAndDoEMFRegistration();
> XtextResourceSet resourceSet =
> injector.getInstance(XtextResourceSet.class);
>
>
> resourceSet.getResource(URI.createFileURI("AbstractToConcrete.qvtr"),
> true);
>
>
>
> by doing this i got an exception on the last line:
>
>
> Exception in thread "main"
> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl$1DiagnosticWrappedException:
> org.xml.sax.SAXParseExceptionpublicId: AbstractToConcrete.qvtr;
> systemId:
> file:///home/tmg/workspace/TesteQVTd/AbstractToConcrete.qvtr;
> lineNumber: 1; columnNumber: 1; Content is not allowed in prolog.
>
>
> Thanks in advance
> Tiago Guimarães
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03310 seconds