Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » QVT-Relations » [help]QVTd as a parser in a standalone application
[help]QVTd as a parser in a standalone application [message #1015205] Wed, 27 February 2013 17:56 Go to next message
Tiago Guimarães is currently offline Tiago Guimarães
Messages: 6
Registered: February 2013
Junior Member
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 19:47 Go to previous messageGo to next message
Ed Willink is currently offline Ed Willink
Messages: 4088
Registered: July 2009
Senior Member
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 12:06 Go to previous messageGo to next message
Tiago Guimarães is currently offline Tiago Guimarães
Messages: 6
Registered: February 2013
Junior Member
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 12:32 Go to previous messageGo to next message
Ed Willink is currently offline Ed Willink
Messages: 4088
Registered: July 2009
Senior Member
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
Re: [help]QVTd as a parser in a standalone application [message #1016424 is a reply to message #1015205] Wed, 06 March 2013 12:08 Go to previous messageGo to next message
Tiago Guimarães is currently offline Tiago Guimarães
Messages: 6
Registered: February 2013
Junior Member
Thanks for your help!


I just have a simple problem with the results now:

I can't tell when a relation is Top or not...

The method I am using is relation.isIsTopLevel() (org.eclipse.qvtd.pivot.qvtrelation.Relation) and it is always returning false...Everything else is working fine, even OCL constraints


I have also noted that on the editor, I can't find the top attribute


Best,
Tiago Guimarães
Re: [help]QVTd as a parser in a standalone application [message #1016559 is a reply to message #1016424] Wed, 06 March 2013 22:28 Go to previous message
Ed Willink is currently offline Ed Willink
Messages: 4088
Registered: July 2009
Senior Member
Hi

Oops. 'top' is not copied from CST to AST. Fix pushed to GIT master. Fix
downloadable now from
https://hudson.eclipse.org/hudson/job/buckminster-mmt-qvtd-kepler/lastSuccessfulBuild/artifact/.
Should be available on the download page and nightly update site tomorrow.

Regards

Ed Willink

On 06/03/2013 12:08, Tiago Guimarães wrote:
> Thanks for your help!
>
>
> I just have a simple problem with the results now:
>
> I can't tell when a relation is Top or not...
>
> The method I am using is relation.isIsTopLevel()
> (org.eclipse.qvtd.pivot.qvtrelation.Relation) and it is always
> returning false...Everything else is working fine, even OCL constraints
>
>
> I have also noted that on the editor, I can't find the top attribute
>
>
> Best,
> Tiago Guimarães
Previous Topic:[Announce] Eclipse QVTd 0.10.0 (Kepler) M5 is now available
Next Topic:objectsOfType don`t return correct results
Goto Forum:
  


Current Time: Wed Oct 22 05:06:44 GMT 2014

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

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