Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc) » External Models with xtext and xpand
| |
Re: External Models with xtext and xpand [message #134193 is a reply to message #134166] |
Sun, 22 March 2009 12:07 |
Sven Efftinge Messages: 1823 Registered: July 2009 |
Senior Member |
|
|
Hi Hasan,
there's currently no way to tell Xtext's ecore model something generator
about default values. So writing the ecore file by hand seems appropriate.
If you reference an Ecore model from a grammar, you have to make sure
that the generator as well as the editor can find that ecore model by
the URI you provided. So for Xtext it's best to use a resoure URI, as in
that case not only the Xtext generator but also the editor will be able
to resolve the reference.
For Xpand to have an ecore file recognized, it needs to be on the
classpath of the project containing the *.xpt, *ext, *.chk files (Those
files too have to be on the classpath, i.e. in some Java package).
This means, that if you want to use Xtext with Xpand, we recommend to
put ecore files into Java src/ folders and reference it via classpath:/
URI (Note that this scheme is introduced in Xtext, and therefore not
generally available in EMF)
Example:
import "classpath:/my/org/mymodel.ecore"
....
Hope that helps,
Sven
Hasan Ceylan schrieb:
> Hello,
>
> I need some defaults in my editor meta model. I could not find a way to
> express a default value for an attribute therefore I factored my meta model
> out of the workflow and started manually coding the model with the defaults
> I like.
>
> Then I ran into a problem:
> 1) I cannot reference the meta model with the uri like
> http://www.mycompany.com/model/1.0 . rather I need to go down the
> platform:/resource the path...
>
> Otherwise I get:
> java.lang.IllegalStateException: Unresolved proxy
> http://www.mycompany.com/model/1.0#//EditorModel. Make sure the EPackage has
> been registered.
>
> 2) Then my xpt, ext and chk files cannot locate the classes nethier the code
> generation from the generator project works, complaining with the same
> problem "cannot find meta model".
>
> My questions are,
> 1) Is there a way to express defaults for the attributes in xtext?
> 2) What is the correct way of using an external editor model for the xtext
> editor and code generation?
>
> Thanks in advance,
> Hasan Ceylan
>
|
|
|
Re: External Models with xtext and xpand [message #134205 is a reply to message #134193] |
Sun, 22 March 2009 17:06 |
Hasan Ceylan Messages: 198 Registered: July 2009 |
Senior Member |
|
|
Hello Sven,
Thanks for the detailed information.
I had seen the classpath-protocol-uris before (in workflows), but I hadn't
really though I could use it here. I'll give it a try...
I noticied one more problem with the external models. If they're used in the
model, then in standalone setup their model is not registered automatically
by the code generated.
I opened up the this bug that I could use as a workaround hope it helps
https://bugs.eclipse.org/bugs/show_bug.cgi?id=269596
Hasan
Sven Efftinge wrote:
> Hi Hasan,
>
> there's currently no way to tell Xtext's ecore model something generator
> about default values. So writing the ecore file by hand seems appropriate.
>
> If you reference an Ecore model from a grammar, you have to make sure
> that the generator as well as the editor can find that ecore model by
> the URI you provided. So for Xtext it's best to use a resoure URI, as in
> that case not only the Xtext generator but also the editor will be able
> to resolve the reference.
>
> For Xpand to have an ecore file recognized, it needs to be on the
> classpath of the project containing the *.xpt, *ext, *.chk files (Those
> files too have to be on the classpath, i.e. in some Java package).
>
> This means, that if you want to use Xtext with Xpand, we recommend to
> put ecore files into Java src/ folders and reference it via classpath:/
> URI (Note that this scheme is introduced in Xtext, and therefore not
> generally available in EMF)
>
> Example:
>
> import "classpath:/my/org/mymodel.ecore"
>
> ...
>
> Hope that helps,
> Sven
>
> Hasan Ceylan schrieb:
>> Hello,
>>
>> I need some defaults in my editor meta model. I could not find a way to
>> express a default value for an attribute therefore I factored my meta
>> model out of the workflow and started manually coding the model with the
>> defaults I like.
>>
>> Then I ran into a problem:
>> 1) I cannot reference the meta model with the uri like
>> http://www.mycompany.com/model/1.0 . rather I need to go down the
>> platform:/resource the path...
>>
>> Otherwise I get:
>> java.lang.IllegalStateException: Unresolved proxy
>> http://www.mycompany.com/model/1.0#//EditorModel. Make sure the EPackage
>> has been registered.
>>
>> 2) Then my xpt, ext and chk files cannot locate the classes nethier the
>> code generation from the generator project works, complaining with the
>> same problem "cannot find meta model".
>>
>> My questions are,
>> 1) Is there a way to express defaults for the attributes in xtext?
>> 2) What is the correct way of using an external editor model for the
>> xtext editor and code generation?
>>
>> Thanks in advance,
>> Hasan Ceylan
>>
|
|
|
Re: External Models with xtext and xpand [message #134218 is a reply to message #134193] |
Sun, 22 March 2009 21:44 |
Hasan Ceylan Messages: 198 Registered: July 2009 |
Senior Member |
|
|
Hello,
I think I spotted some stuff about why xtext misses the metamodels and
contributed a patch in the following bug:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=269635
Hope it helps,
Hasan
Sven Efftinge wrote:
> Hi Hasan,
>
> there's currently no way to tell Xtext's ecore model something generator
> about default values. So writing the ecore file by hand seems appropriate.
>
> If you reference an Ecore model from a grammar, you have to make sure
> that the generator as well as the editor can find that ecore model by
> the URI you provided. So for Xtext it's best to use a resoure URI, as in
> that case not only the Xtext generator but also the editor will be able
> to resolve the reference.
>
> For Xpand to have an ecore file recognized, it needs to be on the
> classpath of the project containing the *.xpt, *ext, *.chk files (Those
> files too have to be on the classpath, i.e. in some Java package).
>
> This means, that if you want to use Xtext with Xpand, we recommend to
> put ecore files into Java src/ folders and reference it via classpath:/
> URI (Note that this scheme is introduced in Xtext, and therefore not
> generally available in EMF)
>
> Example:
>
> import "classpath:/my/org/mymodel.ecore"
>
> ...
>
> Hope that helps,
> Sven
>
> Hasan Ceylan schrieb:
>> Hello,
>>
>> I need some defaults in my editor meta model. I could not find a way to
>> express a default value for an attribute therefore I factored my meta
>> model out of the workflow and started manually coding the model with the
>> defaults I like.
>>
>> Then I ran into a problem:
>> 1) I cannot reference the meta model with the uri like
>> http://www.mycompany.com/model/1.0 . rather I need to go down the
>> platform:/resource the path...
>>
>> Otherwise I get:
>> java.lang.IllegalStateException: Unresolved proxy
>> http://www.mycompany.com/model/1.0#//EditorModel. Make sure the EPackage
>> has been registered.
>>
>> 2) Then my xpt, ext and chk files cannot locate the classes nethier the
>> code generation from the generator project works, complaining with the
>> same problem "cannot find meta model".
>>
>> My questions are,
>> 1) Is there a way to express defaults for the attributes in xtext?
>> 2) What is the correct way of using an external editor model for the
>> xtext editor and code generation?
>>
>> Thanks in advance,
>> Hasan Ceylan
>>
|
|
|
Re: External Models with xtext and xpand [message #620742 is a reply to message #134166] |
Sat, 21 March 2009 11:10 |
Ed Merks Messages: 33137 Registered: July 2009 |
Senior Member |
|
|
Hasan,
I've seen this question recently in the TMF newsgroup so I'm redirecting
your question there by adding it to the "to" list of the reply.
Hasan Ceylan wrote:
> Hello,
>
> I need some defaults in my editor meta model. I could not find a way to
> express a default value for an attribute therefore I factored my meta model
> out of the workflow and started manually coding the model with the defaults
> I like.
>
> Then I ran into a problem:
> 1) I cannot reference the meta model with the uri like
> http://www.mycompany.com/model/1.0 . rather I need to go down the
> platform:/resource the path...
>
> Otherwise I get:
> java.lang.IllegalStateException: Unresolved proxy
> http://www.mycompany.com/model/1.0#//EditorModel Make sure the EPackage has
> been registered.
>
> 2) Then my xpt, ext and chk files cannot locate the classes nethier the code
> generation from the generator project works, complaining with the same
> problem "cannot find meta model".
>
> My questions are,
> 1) Is there a way to express defaults for the attributes in xtext?
> 2) What is the correct way of using an external editor model for the xtext
> editor and code generation?
>
> Thanks in advance,
> Hasan Ceylan
>
>
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Re: External Models with xtext and xpand [message #620743 is a reply to message #134166] |
Sun, 22 March 2009 12:07 |
Sven Efftinge Messages: 1823 Registered: July 2009 |
Senior Member |
|
|
Hi Hasan,
there's currently no way to tell Xtext's ecore model something generator
about default values. So writing the ecore file by hand seems appropriate.
If you reference an Ecore model from a grammar, you have to make sure
that the generator as well as the editor can find that ecore model by
the URI you provided. So for Xtext it's best to use a resoure URI, as in
that case not only the Xtext generator but also the editor will be able
to resolve the reference.
For Xpand to have an ecore file recognized, it needs to be on the
classpath of the project containing the *.xpt, *ext, *.chk files (Those
files too have to be on the classpath, i.e. in some Java package).
This means, that if you want to use Xtext with Xpand, we recommend to
put ecore files into Java src/ folders and reference it via classpath:/
URI (Note that this scheme is introduced in Xtext, and therefore not
generally available in EMF)
Example:
import "classpath:/my/org/mymodel.ecore"
....
Hope that helps,
Sven
Hasan Ceylan schrieb:
> Hello,
>
> I need some defaults in my editor meta model. I could not find a way to
> express a default value for an attribute therefore I factored my meta model
> out of the workflow and started manually coding the model with the defaults
> I like.
>
> Then I ran into a problem:
> 1) I cannot reference the meta model with the uri like
> http://www.mycompany.com/model/1.0 . rather I need to go down the
> platform:/resource the path...
>
> Otherwise I get:
> java.lang.IllegalStateException: Unresolved proxy
> http://www.mycompany.com/model/1.0#//EditorModel Make sure the EPackage has
> been registered.
>
> 2) Then my xpt, ext and chk files cannot locate the classes nethier the code
> generation from the generator project works, complaining with the same
> problem "cannot find meta model".
>
> My questions are,
> 1) Is there a way to express defaults for the attributes in xtext?
> 2) What is the correct way of using an external editor model for the xtext
> editor and code generation?
>
> Thanks in advance,
> Hasan Ceylan
>
|
|
|
Re: External Models with xtext and xpand [message #620744 is a reply to message #134193] |
Sun, 22 March 2009 17:06 |
Hasan Ceylan Messages: 198 Registered: July 2009 |
Senior Member |
|
|
Hello Sven,
Thanks for the detailed information.
I had seen the classpath-protocol-uris before (in workflows), but I hadn't
really though I could use it here. I'll give it a try...
I noticied one more problem with the external models. If they're used in the
model, then in standalone setup their model is not registered automatically
by the code generated.
I opened up the this bug that I could use as a workaround hope it helps
https://bugs.eclipse.org/bugs/show_bug.cgi?id=269596
Hasan
Sven Efftinge wrote:
> Hi Hasan,
>
> there's currently no way to tell Xtext's ecore model something generator
> about default values. So writing the ecore file by hand seems appropriate.
>
> If you reference an Ecore model from a grammar, you have to make sure
> that the generator as well as the editor can find that ecore model by
> the URI you provided. So for Xtext it's best to use a resoure URI, as in
> that case not only the Xtext generator but also the editor will be able
> to resolve the reference.
>
> For Xpand to have an ecore file recognized, it needs to be on the
> classpath of the project containing the *.xpt, *ext, *.chk files (Those
> files too have to be on the classpath, i.e. in some Java package).
>
> This means, that if you want to use Xtext with Xpand, we recommend to
> put ecore files into Java src/ folders and reference it via classpath:/
> URI (Note that this scheme is introduced in Xtext, and therefore not
> generally available in EMF)
>
> Example:
>
> import "classpath:/my/org/mymodel.ecore"
>
> ...
>
> Hope that helps,
> Sven
>
> Hasan Ceylan schrieb:
>> Hello,
>>
>> I need some defaults in my editor meta model. I could not find a way to
>> express a default value for an attribute therefore I factored my meta
>> model out of the workflow and started manually coding the model with the
>> defaults I like.
>>
>> Then I ran into a problem:
>> 1) I cannot reference the meta model with the uri like
>> http://www.mycompany.com/model/1.0 . rather I need to go down the
>> platform:/resource the path...
>>
>> Otherwise I get:
>> java.lang.IllegalStateException: Unresolved proxy
>> http://www.mycompany.com/model/1.0#//EditorModel Make sure the EPackage
>> has been registered.
>>
>> 2) Then my xpt, ext and chk files cannot locate the classes nethier the
>> code generation from the generator project works, complaining with the
>> same problem "cannot find meta model".
>>
>> My questions are,
>> 1) Is there a way to express defaults for the attributes in xtext?
>> 2) What is the correct way of using an external editor model for the
>> xtext editor and code generation?
>>
>> Thanks in advance,
>> Hasan Ceylan
>>
|
|
|
Re: External Models with xtext and xpand [message #620745 is a reply to message #134193] |
Sun, 22 March 2009 21:44 |
Hasan Ceylan Messages: 198 Registered: July 2009 |
Senior Member |
|
|
Hello,
I think I spotted some stuff about why xtext misses the metamodels and
contributed a patch in the following bug:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=269635
Hope it helps,
Hasan
Sven Efftinge wrote:
> Hi Hasan,
>
> there's currently no way to tell Xtext's ecore model something generator
> about default values. So writing the ecore file by hand seems appropriate.
>
> If you reference an Ecore model from a grammar, you have to make sure
> that the generator as well as the editor can find that ecore model by
> the URI you provided. So for Xtext it's best to use a resoure URI, as in
> that case not only the Xtext generator but also the editor will be able
> to resolve the reference.
>
> For Xpand to have an ecore file recognized, it needs to be on the
> classpath of the project containing the *.xpt, *ext, *.chk files (Those
> files too have to be on the classpath, i.e. in some Java package).
>
> This means, that if you want to use Xtext with Xpand, we recommend to
> put ecore files into Java src/ folders and reference it via classpath:/
> URI (Note that this scheme is introduced in Xtext, and therefore not
> generally available in EMF)
>
> Example:
>
> import "classpath:/my/org/mymodel.ecore"
>
> ...
>
> Hope that helps,
> Sven
>
> Hasan Ceylan schrieb:
>> Hello,
>>
>> I need some defaults in my editor meta model. I could not find a way to
>> express a default value for an attribute therefore I factored my meta
>> model out of the workflow and started manually coding the model with the
>> defaults I like.
>>
>> Then I ran into a problem:
>> 1) I cannot reference the meta model with the uri like
>> http://www.mycompany.com/model/1.0 . rather I need to go down the
>> platform:/resource the path...
>>
>> Otherwise I get:
>> java.lang.IllegalStateException: Unresolved proxy
>> http://www.mycompany.com/model/1.0#//EditorModel Make sure the EPackage
>> has been registered.
>>
>> 2) Then my xpt, ext and chk files cannot locate the classes nethier the
>> code generation from the generator project works, complaining with the
>> same problem "cannot find meta model".
>>
>> My questions are,
>> 1) Is there a way to express defaults for the attributes in xtext?
>> 2) What is the correct way of using an external editor model for the
>> xtext editor and code generation?
>>
>> Thanks in advance,
>> Hasan Ceylan
>>
|
|
|
Goto Forum:
Current Time: Sat Apr 20 02:07:08 GMT 2024
Powered by FUDForum. Page generated in 0.03506 seconds
|