Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    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 09:26 Go to next message
Fy Za is currently offline Fy ZaFriend
Messages: 245
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
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 09:49 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
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


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
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 09:52 Go to previous messageGo to next message
Fy Za is currently offline Fy ZaFriend
Messages: 245
Registered: March 2010
Senior Member
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 09:55]

Report message to a 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 09:54 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
https://bugs.eclipse.org/bugs/show_bug.cgi?id=382555

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
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 10:01 Go to previous messageGo to next message
Fy Za is currently offline Fy ZaFriend
Messages: 245
Registered: March 2010
Senior Member
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 10:32 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Simple add both resources (the ecore and the .xtext file) to the same resourceset with getResource and use Xtext 2.3.1

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
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 12:23 Go to previous messageGo to next message
Fy Za is currently offline Fy ZaFriend
Messages: 245
Registered: March 2010
Senior Member
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 12:35 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
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?


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
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 12:39 Go to previous messageGo to next message
Fy Za is currently offline Fy ZaFriend
Messages: 245
Registered: March 2010
Senior Member
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 13:00 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Still No OCL Standard Library content available points to a missing ocl specific setup

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
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 16:23 Go to previous message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
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: Thu Apr 18 01:41:44 GMT 2024

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

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

Back to the top