Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » QVT-OML » OCL Errors in StandAlone QVTo
OCL Errors in StandAlone QVTo [message #1220749] Fri, 13 December 2013 11:43 Go to next message
Arjan  van der Meer is currently offline Arjan van der MeerFriend
Messages: 8
Registered: February 2010
Junior Member
Hello,

I'm trying to run qvto in a standalone application, but every time I try to execute the transformation, I get compiler errors. Most errors I get look like one of these:

Cannot find operation (+(String)) for the type (String) (at:21)
Cannot find operation (selectByType(InterfaceModel)) neither for the type (OrderedSet(Model)) nor for its element type (Model) (at:27)
Unrecognized variable: (interfaces) (at:27)

Based on that, I get the idea OCL is not initialised properly somehow? I tried following the steps for the OCL pivot standalone, but that didn't help. Hw do I fix this?

Is there a full guide somewhere to running OCL standalone? Most of what I can find seems to be partial or is dead.

Regards,
Arjan van der Meer
Re: OCL Errors in StandAlone QVTo [message #1220752 is a reply to message #1220749] Fri, 13 December 2013 11:54 Go to previous messageGo to next message
Denis Nikiforov is currently offline Denis NikiforovFriend
Messages: 343
Registered: August 2013
Senior Member
Hi

Here is my standalone QVTo transformation:
https://github.com/AresEkb/OclToXPath

Here is a package registration:
        Xpath2Package.eINSTANCE.getEFactoryInstance();
        EPackage.Registry.INSTANCE.put("http://www.eclipse.org/xsd/2002/XSD", SchemaPackageImpl.eINSTANCE);

and a transformation part:
        TransformationExecutor executor = new TransformationExecutor(transformation);
        ExecutionContextImpl context = new ExecutionContextImpl();
        context.setConfigProperty("keepModeling", true);
        context.setLog(new WriterLog(new OutputStreamWriter(System.out)));
        ModelExtent input = new BasicModelExtent(source);
        ModelExtent output = new BasicModelExtent();
        ExecutionDiagnostic result = executor.execute(context, input, output);
        if(result.getSeverity() == Diagnostic.OK) {
            return output.getContents();
        } else {
            IStatus status = BasicDiagnostic.toIStatus(result);
            throw new Exception(status.getMessage());
        }

I'm not sure, but maybe OCL must be initalized too:
        org.eclipse.ocl.examples.pivot.OCL.initialize(rs);
        org.eclipse.ocl.examples.pivot.uml.UML2Pivot.initialize(rs);
        org.eclipse.ocl.examples.pivot.model.OCLstdlib.install();
        org.eclipse.ocl.examples.pivot.delegate.OCLDelegateDomain.initialize(rs);
        org.eclipse.ocl.examples.xtext.completeocl.CompleteOCLStandaloneSetup.doSetup();
        org.eclipse.ocl.examples.xtext.oclinecore.OCLinEcoreStandaloneSetup.doSetup();
        org.eclipse.ocl.examples.xtext.oclstdlib.OCLstdlibStandaloneSetup.doSetup();
        org.eclipse.ocl.examples.domain.utilities.StandaloneProjectMap.getAdapter(rs);

Actually I'm new to Eclipse and Java, I apologize if my suggestions will mislead you.
Re: OCL Errors in StandAlone QVTo [message #1220760 is a reply to message #1220752] Fri, 13 December 2013 13:02 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
HI

QVTo does not (yet) use the Pivot version of OCL, so using pivot
installatiion is at best a waste of time and at worst a source of problem.

I would expect QVTo to pretty much just work, perhaps with some help on
the UML registrations; look for an example to copy.

Regards

Ed Willink


On 13/12/2013 11:54, Denis Nikiforov wrote:
> Hi
>
> Here is my standalone QVTo transformation:
> https://github.com/AresEkb/OclToXPath
>
> Here is a package registration:
> Xpath2Package.eINSTANCE.getEFactoryInstance();
> EPackage.Registry.INSTANCE.put("http://www.eclipse.org/xsd/2002/XSD",
> SchemaPackageImpl.eINSTANCE);
> and a transformation part:
> TransformationExecutor executor = new
> TransformationExecutor(transformation);
> ExecutionContextImpl context = new ExecutionContextImpl();
> context.setConfigProperty("keepModeling", true);
> context.setLog(new WriterLog(new OutputStreamWriter(System.out)));
> ModelExtent input = new BasicModelExtent(source);
> ModelExtent output = new BasicModelExtent();
> ExecutionDiagnostic result = executor.execute(context, input,
> output);
> if(result.getSeverity() == Diagnostic.OK) {
> return output.getContents();
> } else {
> IStatus status = BasicDiagnostic.toIStatus(result);
> throw new Exception(status.getMessage());
> }
> I'm not sure, but maybe OCL must be initalized too:
> org.eclipse.ocl.examples.pivot.OCL.initialize(rs);
> org.eclipse.ocl.examples.pivot.uml.UML2Pivot.initialize(rs);
> org.eclipse.ocl.examples.pivot.model.OCLstdlib.install();
> org.eclipse.ocl.examples.pivot.delegate.OCLDelegateDomain.initialize(rs);
> org.eclipse.ocl.examples.xtext.completeocl.CompleteOCLStandaloneSetup.doSetup();
> org.eclipse.ocl.examples.xtext.oclinecore.OCLinEcoreStandaloneSetup.doSetup();
> org.eclipse.ocl.examples.xtext.oclstdlib.OCLstdlibStandaloneSetup.doSetup();
> org.eclipse.ocl.examples.domain.utilities.StandaloneProjectMap.getAdapter(rs);
> Actually I'm new to Eclipse and Java, I apologize if my suggestions
> will mislead you.
Re: OCL Errors in StandAlone QVTo [message #1220784 is a reply to message #1220760] Fri, 13 December 2013 14:57 Go to previous messageGo to next message
Arjan  van der Meer is currently offline Arjan van der MeerFriend
Messages: 8
Registered: February 2010
Junior Member
Hello,

Thanks for the example, it did make things clearer, but unfortunately it didn't resolve the problem.

That code seems essentially the same as what I use. I dynamically load the relevant packages but that should make no difference.

The reason that I mentioned Pivot OCL is that some of the errors go away if I replace 'string' + 'string' with 'string'.concat('string'). That led me to suspect I had the wrong OCL implementation, or that my OCL was somehow incomplete. I seem to recall that both the + for strings and selectByType are (technically) OCL extensions. Do I need to do something special for those?
Re: OCL Errors in StandAlone QVTo [message #1220793 is a reply to message #1220784] Fri, 13 December 2013 15:36 Go to previous message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

String::'+' has always been in QVT and so QVTo.

Promotion of String::'+' to OCL and so Eclipse OCL cam e more recently,
but it should be in Juno and c ertainly Kepler.

selectByType is new in Kepler (and will be in OCL 2.4 as soon as the OMG
rubber stamp is applied). It was backported to the classic OPCL and so
should be in QVTo too.

[You almost never want selectByType or oclIsTypeOf; use selectByKind and
oclIsKindOf].

Regards

Ed Willink


On 13/12/2013 14:57, Arjan van der Meer wrote:
> Hello,
>
> Thanks for the example, it did make things clearer, but unfortunately
> it didn't resolve the problem.
>
> That code seems essentially the same as what I use. I dynamically load
> the relevant packages but that should make no difference.
> The reason that I mentioned Pivot OCL is that some of the errors go
> away if I replace 'string' + 'string' with 'string'.concat('string').
> That led me to suspect I had the wrong OCL implementation, or that my
> OCL was somehow incomplete. I seem to recall that both the + for
> strings and selectByType are (technically) OCL extensions. Do I need
> to do something special for those?
Previous Topic:How to create javax.xml.namespace.QName?
Next Topic:Execute native OCL query in qvt-o code
Goto Forum:
  


Current Time: Tue Apr 23 09:31:38 GMT 2024

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

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

Back to the top