Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » import ecore model using nsURI
import ecore model using nsURI [message #1063813] Fri, 14 June 2013 11:10 Go to next message
Ravasz Roka is currently offline Ravasz RokaFriend
Messages: 3
Registered: June 2013
Junior Member
Hi,

I created an ecore model that has a package called library with nsURI
http://<someurl>

I have also a genmodel for this ecore model and generated the model code.
Next, I tried to create an xtext project based on the ecore model (wizard).
The wizard generates me an xtext where I also have the line
import "http://<someurl>" as library


I get the error message
couldn't resolve reference to EPackage "http://<someurl>"


what am I missing? Shouldn't the wizard generate error-free code?

thanks,
ravasz roka
Re: import ecore model using nsURI [message #1103135 is a reply to message #1063813] Fri, 06 September 2013 12:13 Go to previous messageGo to next message
Mathieu MONTIN is currently offline Mathieu MONTINFriend
Messages: 26
Registered: October 2012
Junior Member
Hello guys,

I have the same problem, and when I import the model without its nsURI like this :

import "platform:/randomPath/randomFile.ecore" it works but only with a warning and it does not import the subpackages in the ecore file, which I need the most.

Does anyone have an answer to this problem ?
Re: import ecore model using nsURI [message #1103141 is a reply to message #1103135] Fri, 06 September 2013 12:16 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 6550
Registered: July 2009
Senior Member
Hmm did you try to import the sub packages explicit

Platform:/resouce./project/path/file.ecore#package

--
Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext at itemis dot de
Re: import ecore model using nsURI [message #1103142 is a reply to message #1103135] Fri, 06 September 2013 12:16 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 6550
Registered: July 2009
Senior Member
BTW why don't you use ns uri?

--
Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext at itemis dot de
Re: import ecore model using nsURI [message #1103154 is a reply to message #1103142] Fri, 06 September 2013 12:35 Go to previous messageGo to next message
Mathieu MONTIN is currently offline Mathieu MONTINFriend
Messages: 26
Registered: October 2012
Junior Member
Thanks for you answer.

I wish I could use nsURI, but xtext is unable to find the uri of my metamodel. This is why I had to swich to direct import, but it does not work either.

I mean, it works for the ecore file with the warning :
"The imported package is not on the classpath of this project which may lead to follow up errors."

But it does not work with #<Mypackage> at the end.

Is there any way I can make xtext find my ePackages ? I'd really like to use nsURI because it makes more sense anyway.

Maybe I miss something very simple, but I just wish I could solve it.

I read a lot of posts and I know there is something to add in the workflow file, but it is supposed to come after. I suppose there is no point modifying it if xtext does not even find my packages.
Re: import ecore model using nsURI [message #1103167 is a reply to message #1063813] Fri, 06 September 2013 12:51 Go to previous messageGo to next message
Mathieu MONTIN is currently offline Mathieu MONTINFriend
Messages: 26
Registered: October 2012
Junior Member
btw it also fails solving the URI if I use the wizard to create an xtext project from and existing ecore metamodel.
Re: import ecore model using nsURI [message #1103173 is a reply to message #1103167] Fri, 06 September 2013 12:58 Go to previous messageGo to next message
Mathieu MONTIN is currently offline Mathieu MONTINFriend
Messages: 26
Registered: October 2012
Junior Member
I read somewhere that it might be caused by my packages not being properly indexed.

What could I do to solve this ?
Re: import ecore model using nsURI [message #1103182 is a reply to message #1103173] Fri, 06 September 2013 13:10 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 6550
Registered: July 2009
Senior Member
hi,

did you add xtext nature to the project containing the ecore.
is it a package you have under control? is it existing or not?
if you are just about to creating it then avoid subpackages.
Re: import ecore model using nsURI [message #1103186 is a reply to message #1103182] Fri, 06 September 2013 13:14 Go to previous messageGo to next message
Mathieu MONTIN is currently offline Mathieu MONTINFriend
Messages: 26
Registered: October 2012
Junior Member
I did not add the xtext nature, I will try right away.

Concerning the subpackages, I can't really avoid it right now, but why should I anyway?
Re: import ecore model using nsURI [message #1103190 is a reply to message #1103182] Fri, 06 September 2013 13:16 Go to previous messageGo to next message
Mathieu MONTIN is currently offline Mathieu MONTINFriend
Messages: 26
Registered: October 2012
Junior Member
It works !!

I knew this would be just a little tweak but ...

Thank you very much !
Re: import ecore model using nsURI [message #1103297 is a reply to message #1103190] Fri, 06 September 2013 15:39 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 6550
Registered: July 2009
Senior Member
btw: import "platform:/resource/test/model/test.ecore#//sub" works as well
Re: import ecore model using nsURI [message #1105777 is a reply to message #1063813] Tue, 10 September 2013 09:02 Go to previous messageGo to next message
Mathieu MONTIN is currently offline Mathieu MONTINFriend
Messages: 26
Registered: October 2012
Junior Member
Hello again,

Now that I have imported my other ecore model (and subpackages) there is an issue with the linking between the models.

In my runtime Eclipse, I try to use the reference I made in my xtext metamodel but it fails to autocomplete anything and when I edit my model through the Emf editor, I am able to link the current model to other elements but it fails when I save.

My feeling is that when I save my model, xtext serializer is called to modify the text version of my model, but it fails serializing the linked elements because they are not part of an xtext Resource.

This is just my feeling but if it turns out that this really is the issue, do I have to create an xtext project from an existing resource just to get the serializer of one element ?

I read somewhere that by default, xtext takes the feature "name" as an ID. My imported element does contain a feature "name" but that does not seem to do the job anyway.
Re: import ecore model using nsURI [message #1105786 is a reply to message #1105777] Tue, 10 September 2013 09:16 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 6550
Registered: July 2009
Senior Member
Hi,

if you have an emf editor you need to provide a resourceserviceprovider
http://christiandietrich.wordpress.com/2011/07/17/xtext-2-0-and-uml/
(will not be that complicated in your case i guess)
Re: import ecore model using nsURI [message #1105970 is a reply to message #1105786] Tue, 10 September 2013 14:10 Go to previous messageGo to next message
Mathieu MONTIN is currently offline Mathieu MONTINFriend
Messages: 26
Registered: October 2012
Junior Member
Thank's for the link.

I've followed the post step by step. I've created the two projects and I've adapted their content to my case.

I've also added to those project the xtext nature (just in case). However, I still don't get any autocompletion and I can't save any file I modified with my EMF editor (it still looks like xtext is not able to serialize anything that does not belong to it in the first place).

Anyway, I've put a random print is the method "getLanguageName" in my runtime module and this method seems to be just ignored. It's like everything I've created is not even called.

In a way, it looks logical because we never really create links between what we build and the target dsl (in your case uml). The only link I've been able to spot is the one with the UMLEditor.

Have I missed something ? You do some weird changes in your workflow which I couldnt understand nor reproduce, and maybe this is why it failed.

What do you think ?

EDIT : now the method getLanguage is called, after some tweaks, but it still does not do what I was expected.

[Updated on: Tue, 10 September 2013 14:20]

Report message to a moderator

Re: import ecore model using nsURI [message #1105993 is a reply to message #1105970] Tue, 10 September 2013 14:40 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 6550
Registered: July 2009
Senior Member
Hi,

maybe i did not get your usecase. can you please elaborate one more what you are doing (with sample code)?
Re: import ecore model using nsURI [message #1106007 is a reply to message #1105993] Tue, 10 September 2013 14:57 Go to previous messageGo to next message
Mathieu MONTIN is currently offline Mathieu MONTINFriend
Messages: 26
Registered: October 2012
Junior Member
sure !

(meanwhile, I keep trying with your example because I think this might be the answer).

I have a MM "A.ecore" which defines a class ICDEntry :
    <eClassifiers xsi:type="ecore:EClass" name="ICDEntry">
      <eStructuralFeatures xsi:type="ecore:EAttribute" name="name" lowerBound="1"
          eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"
          iD="true"/>
      <eStructuralFeatures xsi:type="ecore:EReference" name="features" eType="#//ICD/Features"
          containment="true"/>
      <eStructuralFeatures xsi:type="ecore:EAttribute" name="type" lowerBound="1"
          eType="#//ICD/VariableType" defaultValueLiteral="INTEGER"/>
      <eStructuralFeatures xsi:type="ecore:EAttribute" name="min" lowerBound="1" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"
          defaultValueLiteral=""/>
      <eStructuralFeatures xsi:type="ecore:EAttribute" name="max" lowerBound="1" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"
          defaultValueLiteral=""/>
      <eStructuralFeatures xsi:type="ecore:EAttribute" name="dim1" lowerBound="1"
          eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"
          defaultValueLiteral=""/>
      <eStructuralFeatures xsi:type="ecore:EAttribute" name="dim2" lowerBound="1"
          eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"
          defaultValueLiteral=""/>
    </eClassifiers>


I have created an XText grammar in which there is a reference to an element of type "ICDEntry" like this :

VariableExpression returns AbstractExpression :
	{VariableExpression} variable=[icd::ICDEntry]
;


But when I edit some files from that grammar, there is no autocompletion whatsoever. So I tried to edit those files with the classical EMF editor, and, after loading the proper resource, I am able to link an ICDEntry. However, when I try to save the file, it fails with and error, probably because xtext isnt able to serialize any element of type ICDEntry.

The post you link seems to fit my problem, but maybe those explanations will make you understand a bit more what kind of issue I am facing.

Anyway, thank's for you help and time.

EDIT : here is what I changed in my workflow :

    bean = StandaloneSetup {
            scanClassPath = true
            platformUri = "${runtimeProject}/.."
            // The following two lines can be removed, if Xbase is not used.
            registerGeneratedEPackage = "org.eclipse.xtext.xbase.XbasePackage"
            registerGenModelFile = "platform:/resource/org.eclipse.xtext.xbase/model/Xbase.genmodel"
	   registerGeneratedEPackage = "simulator.ICD.ICDPackage"
	   registerGenModelFile = "platform:/resource/org.sengs.simulator/model/simulator.genmodel"
        }

[Updated on: Tue, 10 September 2013 15:01]

Report message to a moderator

Re: import ecore model using nsURI [message #1106037 is a reply to message #1106007] Tue, 10 September 2013 15:41 Go to previous messageGo to next message
Mathieu MONTIN is currently offline Mathieu MONTINFriend
Messages: 26
Registered: October 2012
Junior Member
I found an error in my grammar which was leading to the lack of autocompletion : I had to specify (as you did in your example) the syntax of the name of my ICDEntry element, while I was assuming that the ID rule was enough.

But I still get weird exceptions each time I launch pretty much anything from my runtime Eclipse. It looks like this :

Caused by: org.eclipse.xtext.resource.FileNotFoundOnClasspathException: Couldn't find resource on classpath. URI was 'classpath:/org/eclipse/papyrus/uml/textedit/common/xtext/UmlCommon.xmi'
	at org.eclipse.xtext.resource.ClassloaderClasspathUriResolver.findResourceOnClasspath(ClassloaderClasspathUriResolver.java:60)
	at org.eclipse.xtext.resource.ClassloaderClasspathUriResolver.resolve(ClassloaderClasspathUriResolver.java:45)
	... 126 more


Thanks a lot for your help and if you have any idea about this exception that floods my console, please let me know.

thanks again !
Re: import ecore model using nsURI [message #1107310 is a reply to message #1063813] Thu, 12 September 2013 08:22 Go to previous messageGo to next message
Mathieu MONTIN is currently offline Mathieu MONTINFriend
Messages: 26
Registered: October 2012
Junior Member
Anybody knows about this exception ?

It comes from the injector but I really can't figure out what the problem is.

Maybe there are hidden dependencies to this URI, in which case I should prob install it, but I don't see any reason why my project should depend on UML, for instance.

[Updated on: Thu, 12 September 2013 08:25]

Report message to a moderator

Re: import ecore model using nsURI [message #1107317 is a reply to message #1107310] Thu, 12 September 2013 08:32 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 6550
Registered: July 2009
Senior Member
Hi,

have no idea. sure the classpath is right?
Re: import ecore model using nsURI [message #1107333 is a reply to message #1107317] Thu, 12 September 2013 08:57 Go to previous message
Mathieu MONTIN is currently offline Mathieu MONTINFriend
Messages: 26
Registered: October 2012
Junior Member
pretty much, I never had classpath issues before that.

I found a bug report (mentioned as solved) that exactly fits my prob :
https://bugs.eclipse.org/bugs/show_bug.cgi?format=multiple&id=400395

But it does not solve it, as you can see.
Previous Topic:Best way to reuse xtext grammar in GMF editor
Next Topic:Hyperlink customization
Goto Forum:
  


Current Time: Sat Dec 20 13:06:39 GMT 2014

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

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