Skip to main content



      Home
Home » Modeling » TMF (Xtext) » parsed CompleteOCL file doesn't resolve cross reference to the ecore referenced file
parsed CompleteOCL file doesn't resolve cross reference to the ecore referenced file [message #928088] Sun, 30 September 2012 05:26 Go to next message
Eclipse UserFriend
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
Re: parsed CompleteOCL file doesn't resolve cross reference to the ecore referenced file [message #928101 is a reply to message #928088] Sun, 30 September 2012 05:49 Go to previous messageGo to next message
Eclipse UserFriend
Hi,

first you should call getresource and not createresource
which Xtext Version do you use. There is a Bug on Standalone Cross Refs in 2.3.0 that is fixed in 2.3.1
Re: parsed CompleteOCL file doesn't resolve cross reference to the ecore referenced file [message #928105 is a reply to message #928101] Sun, 30 September 2012 05:52 Go to previous messageGo to next message
Eclipse UserFriend
Hi,
I use Xtext SDK 2.3.0.v201206120633
I update the version to 2.3.1.
Can you please explain how modify the code.

Best regards,
Fy Za

[Updated on: Sun, 30 September 2012 05:55] by Moderator

Re: parsed CompleteOCL file doesn't resolve cross reference to the ecore referenced file [message #928106 is a reply to message #928105] Sun, 30 September 2012 05:54 Go to previous messageGo to next message
Eclipse UserFriend
https://bugs.eclipse.org/bugs/show_bug.cgi?id=382555
Re: parsed CompleteOCL file doesn't resolve cross reference to the ecore referenced file [message #928113 is a reply to message #928106] Sun, 30 September 2012 06:01 Go to previous messageGo to next message
Eclipse UserFriend
Hi Christian,
Thank you!
Can you give me a parsing code of an example of an xtext file which refers to an ecore metamodel.

Fy Za
Re: parsed CompleteOCL file doesn't resolve cross reference to the ecore referenced file [message #928134 is a reply to message #928113] Sun, 30 September 2012 06:32 Go to previous messageGo to next message
Eclipse UserFriend
Simple add both resources (the ecore and the .xtext file) to the same resourceset with getResource and use Xtext 2.3.1
Re: parsed CompleteOCL file doesn't resolve cross reference to the ecore referenced file [message #928204 is a reply to message #928134] Sun, 30 September 2012 08:23 Go to previous messageGo to next message
Eclipse UserFriend
Hi,
I modify it in like this

public class Parser {

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

		CompleteOCLStandaloneSetup.doSetup();
		ResourceSet resourceSet = new ResourceSetImpl();
		Resource resource = resourceSet.getResource(URI.createURI(args[0]), true);
		resource.load(null);
		
		Resource resource1 = resourceSet.getResource(URI.createURI("src/MyDSL.ecore"), true);
		resource1.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));

	}
}

but, I have 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:36)
Re: parsed CompleteOCL file doesn't resolve cross reference to the ecore referenced file [message #928214 is a reply to message #928204] Sun, 30 September 2012 08:35 Go to previous messageGo to next message
Eclipse UserFriend
HI,

i dont know the ocl stuff but why do you do this xmi thing?
it seems that there is something missing on the classpath and or in the resourceset.
does this ocl stuff not have any example code for project setup?
Re: parsed CompleteOCL file doesn't resolve cross reference to the ecore referenced file [message #928218 is a reply to message #928214] Sun, 30 September 2012 08:39 Go to previous messageGo to next message
Eclipse UserFriend
Hi,
After this, I will transform the xmi file (the ocl property).

when I comment this line,
//EcoreUtil.resolveAll(resource);

it works but without resolve crosss reference
Re: parsed CompleteOCL file doesn't resolve cross reference to the ecore referenced file [message #928232 is a reply to message #928218] Sun, 30 September 2012 09:00 Go to previous messageGo to next message
Eclipse UserFriend
Still No OCL Standard Library content available points to a missing ocl specific setup
Re: parsed CompleteOCL file doesn't resolve cross reference to the ecore referenced file [message #928437 is a reply to message #928232] Sun, 30 September 2012 12:23 Go to previous message
Eclipse UserFriend
Hi

This is not an Xtext issue. Pleasew use he OCL newsgroup for
OCL-specific questions.

You may look at the OCL JUnit tests for many examples of how to use
Xtext initilaisation, URI intitialisation.

You should never create a resource directly for an Xtext resource.

Regards

Ed Willink

On 30/09/2012 15:00, Christian Dietrich wrote:
> Still No OCL Standard Library content available points to a missing
> ocl specific setup
Previous Topic:Extend xtend with more extension methods
Next Topic:Getting text in StatefulFactory
Goto Forum:
  


Current Time: Mon Jul 07 22:09:48 EDT 2025

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

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

Back to the top