Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » parsed CompleteOCL file doesn't resolve cross reference
parsed CompleteOCL file doesn't resolve cross reference [message #928078] Sun, 30 September 2012 05:10 Go to next message
Fi Fi is currently offline Fi Fi
Messages: 133
Registered: March 2010
Senior Member
I define my file test.ocl using
completeocl sources (org.eclipse.ocl.examples.xtext.completeocl -> Run As Eclipse Application)

import 'MyEcore.ecore'
package test

context TestClass
...
....


I try after to parse this file using Xtext.
package fr.enseeiht.completeocl.parser;

import java.io.IOException;
import java.util.Map;

import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl;
import org.eclipse.ocl.examples.xtext.completeocl.CompleteOCLStandaloneSetup;







public class Parser {

	public static void main(String[] args) throws IOException {

		CompleteOCLStandaloneSetup.doSetup();
		ResourceSet resourceSet = new ResourceSetImpl();
		Resource resource = resourceSet.createResource(URI.createURI(args[0]));
		resource.load(null);
		
		Resource.Factory.Registry reg = Resource.Factory.Registry.INSTANCE;
		Map<String, Object> m = reg.getExtensionToFactoryMap();
		m.put("completeocl", new XMIResourceFactoryImpl());
		
		EcoreUtil.resolveAll(resource); 
		
		Resource resourceAsXmi = resourceSet.createResource(URI.createURI(args[0].substring(0, args[0].length()-4)+".completeOCLCST"));
		resourceAsXmi.getContents().addAll(resource.getContents());
		resourceAsXmi.save(null);
		System.out.println(args[0].substring(0, args[0].length()-5));

	}
}



I get this error

Exception in thread "main" org.eclipse.ocl.examples.pivot.utilities.IllegalLibraryException: No OCL Standard Library content available
	at org.eclipse.ocl.examples.pivot.manager.PivotStandardLibrary.getRequiredLibraryType(PivotStandardLibrary.java:277)
	at org.eclipse.ocl.examples.pivot.manager.PivotStandardLibrary.resolveRequiredSimpleType(PivotStandardLibrary.java:376)
	at org.eclipse.ocl.examples.pivot.manager.PivotStandardLibrary.getOclInvalidType(PivotStandardLibrary.java:206)
	at org.eclipse.ocl.examples.xtext.base.baseCST.impl.PathElementCSImpl.getElement(PathElementCSImpl.java:354)
	at org.eclipse.ocl.examples.xtext.base.baseCST.impl.PathNameCSImpl.getElement(PathNameCSImpl.java:390)
	at org.eclipse.ocl.examples.xtext.completeocl.completeOCLCST.impl.ClassifierContextDeclCSImpl.getClassifier(ClassifierContextDeclCSImpl.java:201)
	at org.eclipse.ocl.examples.xtext.completeocl.completeOCLCST.impl.ClassifierContextDeclCSImpl.eIsSet(ClassifierContextDeclCSImpl.java:168)
	at org.eclipse.emf.ecore.impl.BasicEObjectImpl.eIsSet(BasicEObjectImpl.java:1237)
	at org.eclipse.emf.ecore.util.EContentsEList$FeatureIteratorImpl.hasNext(EContentsEList.java:401)
	at org.eclipse.emf.ecore.util.EContentsEList$FeatureIteratorImpl.next(EContentsEList.java:559)
	at org.eclipse.emf.ecore.util.EcoreUtil.resolveCrossReferences(EcoreUtil.java:302)
	at org.eclipse.emf.ecore.util.EcoreUtil.resolveAll(EcoreUtil.java:296)
	at org.eclipse.emf.ecore.util.EcoreUtil.resolveAll(EcoreUtil.java:281)
	at fr.enseeiht.completeocl.parser.Parser.main(Parser.java:33)



and if I comment this line
//EcoreUtil.resolveAll(resource); 


My OCL file is parsed but without resolve cross references:
For example,
the
import 'SimplePDL.ecore'

is parsed as
 <element xsi:type="pivot:Annotation" href="/location path ...../test.ocl#xtextLink_::0.10.0.6.1.0::2::/1"/>


Can you please help me to resolve this problem

Best regards,
Thanks

[Updated on: Sun, 30 September 2012 05:10]

Report message to a moderator

Re: parsed CompleteOCL file doesn't resolve cross reference [message #928447 is a reply to message #928078] Sun, 30 September 2012 12:33 Go to previous messageGo to next message
Ed Willink is currently offline Ed Willink
Messages: 4003
Registered: July 2009
Senior Member
On 30/09/2012 11:10, Fy Za wrote:
> No OCL Standard Library content available
This means that no OCL Standard Library has been defined; see
http://help.eclipse.org/juno/index.jsp?topic=%2Forg.eclipse.ocl.doc%2Fhelp%2FPivotStandalone.html.

Regards

Ed Willink
Re: parsed CompleteOCL file doesn't resolve cross reference [message #932771 is a reply to message #928447] Thu, 04 October 2012 08:09 Go to previous messageGo to next message
Fi Fi is currently offline Fi Fi
Messages: 133
Registered: March 2010
Senior Member
Hi Ed,
thank you for reply.
what about serializing an completeocl document?
I try to generate an xmi file from the texutal one.

Thanks
Re: parsed CompleteOCL file doesn't resolve cross reference [message #932810 is a reply to message #932771] Thu, 04 October 2012 08:55 Go to previous message
Ed Willink is currently offline Ed Willink
Messages: 4003
Registered: July 2009
Senior Member
Hi

It should be possible to save either a CS or Pivot resource as XMI. For
the CS you need to use the standard Xtext trick of copying the content
to an XMIResource.

Regards

Ed

On 04/10/2012 14:09, Fy Za wrote:
> Hi Ed,
> thank you for reply.
> what about serializing an completeocl document?
> I try to generate an xmi file from the texutal one.
>
> Thanks
Previous Topic:[Announce] Eclipse OCL 4.1.0 (Kepler) M2 is now available
Next Topic:extending OCL MDT with "just" a temporal operator always
Goto Forum:
  


Current Time: Fri Jul 25 09:44:53 EDT 2014

Powered by FUDForum. Page generated in 0.01709 seconds