Home » Modeling » TMF (Xtext) » XtextResource to XMI
XtextResource to XMI [message #62859] |
Wed, 22 July 2009 16:50 ![Go to next message Go to next message](theme/Solstice/images/down.png) |
Eclipse User![Friend of Eclipse Friend](/donate/web-api/friends_decorator.php?email=) |
|
|
|
Originally posted by: panajotes.gmx.de
Hi,
Is there an easy way to serialize an EMF model represented by an
XtestResource to XMI? I really would like to use Xtext in order to describe
my ecore models in a textual way but still store it as XMI (or as a text
file depending on the user). Do I need to write a custom Serializer in order
to achieve that?
Regards,
Thomas.
|
|
| |
Re: XtextResource to XMI [message #62898 is a reply to message #62885] |
Thu, 23 July 2009 06:15 ![Go to previous message Go to previous message](theme/Solstice/images/up.png) ![Go to next message Go to next message](theme/Solstice/images/down.png) |
Michael Mühlberg![Friend of Eclipse Friend](/donate/web-api/friends_decorator.php?email=michael.muehlberg%40sap.com) Messages: 33 Registered: July 2009 |
Member |
|
|
Hello Sebastian,
as far as I understood it, in this case, every graphical information, or,
everything, which is not modelled, like comments, line breaks, spaces, is
not serialized and therefore lost.
Is that correct?
Ciao, Michael
"Sebastian Zarnekow" <Sebastian.Zarnekow@itemis.de> wrote in message
news:h47qlu$k27$2@build.eclipse.org...
> Hi Thomas,
>
> something like this should work:
>
> XtextResource xtextRes = ...;
> XmiResource xmiRes = new XmiResourceFactoryImpl().createResource(..);
> xmiRes.getContents().add(xtextRes.getContents().get(0));
> xmiRes.save(..);
>
> Hope that helps,
> Sebastian
>
> --
> Need professional support for Eclipse Modeling?
> Go visit: http://xtext.itemis.com
>
> Am 22.07.2009 18:50 Uhr, schrieb Thomas:
>> Hi,
>>
>> Is there an easy way to serialize an EMF model represented by an
>> XtestResource to XMI? I really would like to use Xtext in order to
>> describe my ecore models in a textual way but still store it as XMI (or
>> as a text file depending on the user). Do I need to write a custom
>> Serializer in order to achieve that?
>>
>> Regards,
>> Thomas.
|
|
|
Re: XtextResource to XMI [message #62899 is a reply to message #62898] |
Thu, 23 July 2009 06:33 ![Go to previous message Go to previous message](theme/Solstice/images/up.png) ![Go to next message Go to next message](theme/Solstice/images/down.png) |
Miles Parker![Friend of Eclipse Friend](/donate/web-api/friends_decorator.php?email=milesparker%40gmail.com) Messages: 1341 Registered: July 2009 |
Senior Member |
|
|
You might want to take look at the docs section under hidden terminal
symbols, as well as look at the bits on whitespace. By modifying that
stuff you can make any of these typically ignored tokens semantic and
thus have them included in your model. Of course at some point then you
may as well have your model in plain text. :) But I can see where it
makes sense to do this kind of thing if you want to be able to
reconstruct an entire piece of user code from a well structured
artifact.
hth, Miles
On 2009-07-22 23:15:59 -0700, "Michael Mühlberg"
<michael.muehlberg@sap.com> said:
> Hello Sebastian,
>
> as far as I understood it, in this case, every graphical information, or,
> everything, which is not modelled, like comments, line breaks, spaces, is
> not serialized and therefore lost.
>
> Is that correct?
>
> Ciao, Michael
>
>
>
> "Sebastian Zarnekow" <Sebastian.Zarnekow@itemis.de> wrote in message
> news:h47qlu$k27$2@build.eclipse.org...
>> Hi Thomas,
>>
>> something like this should work:
>>
>> XtextResource xtextRes = ...;
>> XmiResource xmiRes = new XmiResourceFactoryImpl().createResource(..);
>> xmiRes.getContents().add(xtextRes.getContents().get(0));
>> xmiRes.save(..);
>>
>> Hope that helps,
>> Sebastian
>>
>> --
>> Need professional support for Eclipse Modeling?
>> Go visit: http://xtext.itemis.com
>>
>> Am 22.07.2009 18:50 Uhr, schrieb Thomas:
>>> Hi,
>>>
>>> Is there an easy way to serialize an EMF model represented by an
>>> XtestResource to XMI? I really would like to use Xtext in order to
>>> describe my ecore models in a textual way but still store it as XMI (or
>>> as a text file depending on the user). Do I need to write a custom
>>> Serializer in order to achieve that?
>>>
>>> Regards,
>>> Thomas.
|
|
|
Re: XtextResource to XMI [message #62903 is a reply to message #62898] |
Thu, 23 July 2009 08:27 ![Go to previous message Go to previous message](theme/Solstice/images/up.png) ![Go to next message Go to next message](theme/Solstice/images/down.png) |
Sebastian Zarnekow![Friend of Eclipse Friend](/donate/web-api/friends_decorator.php?email=sebastian.zarnekow%40gmail.com) Messages: 3118 Registered: July 2009 |
Senior Member |
|
|
Hi Michael,
this is correct. As whitespace and comments are not part of typical
semantic models, they get lost when you serialize your model as XMI.
You may try to serialize the attached node model as xmi to keep all this
information. Have a look at NodeUtil.getNodeAdapter(eObject).
Regards,
Sebastian
--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com
Am 23.07.2009 8:15 Uhr, schrieb Michael Mühlberg:
> Hello Sebastian,
>
> as far as I understood it, in this case, every graphical information, or,
> everything, which is not modelled, like comments, line breaks, spaces, is
> not serialized and therefore lost.
>
> Is that correct?
>
> Ciao, Michael
>
>
>
> "Sebastian Zarnekow"<Sebastian.Zarnekow@itemis.de> wrote in message
> news:h47qlu$k27$2@build.eclipse.org...
>> Hi Thomas,
>>
>> something like this should work:
>>
>> XtextResource xtextRes = ...;
>> XmiResource xmiRes = new XmiResourceFactoryImpl().createResource(..);
>> xmiRes.getContents().add(xtextRes.getContents().get(0));
>> xmiRes.save(..);
>>
>> Hope that helps,
>> Sebastian
>>
>> --
>> Need professional support for Eclipse Modeling?
>> Go visit: http://xtext.itemis.com
>>
>> Am 22.07.2009 18:50 Uhr, schrieb Thomas:
>>> Hi,
>>>
>>> Is there an easy way to serialize an EMF model represented by an
>>> XtestResource to XMI? I really would like to use Xtext in order to
>>> describe my ecore models in a textual way but still store it as XMI (or
>>> as a text file depending on the user). Do I need to write a custom
>>> Serializer in order to achieve that?
>>>
>>> Regards,
>>> Thomas.
>
>
|
|
|
Re: XtextResource to XMI [message #62946 is a reply to message #62885] |
Thu, 23 July 2009 18:24 ![Go to previous message Go to previous message](theme/Solstice/images/up.png) ![Go to next message Go to next message](theme/Solstice/images/down.png) |
Eclipse User![Friend of Eclipse Friend](/donate/web-api/friends_decorator.php?email=) |
|
|
|
Originally posted by: panajotes.gmx.de
Hi,
where do I get the XtextResource instance from? I tried the following in the
UI-plugin but did not succeed:
private XtextResource
getXtextResource(org.eclipse.core.ressources.IResource resource) throws
IOException{
XtextResource xtextRes = new XtextResource();
xtextRes.load(new FileInputStream(resource.getLocation.toFile()), new
HashMap<String,String>());
return xtextRes;
}
The problem is that the parser is not injected into the XtextResource which
results in a NullPointerException in the "doLoad" method.
Do you have a hint for me?
Regards,
Thomas.
"Sebastian Zarnekow" <Sebastian.Zarnekow@itemis.de> wrote in message
news:h47qlu$k27$2@build.eclipse.org...
> Hi Thomas,
>
> something like this should work:
>
> XtextResource xtextRes = ...;
> XmiResource xmiRes = new XmiResourceFactoryImpl().createResource(..);
> xmiRes.getContents().add(xtextRes.getContents().get(0));
> xmiRes.save(..);
>
> Hope that helps,
> Sebastian
>
> --
> Need professional support for Eclipse Modeling?
> Go visit: http://xtext.itemis.com
>
> Am 22.07.2009 18:50 Uhr, schrieb Thomas:
>> Hi,
>>
>> Is there an easy way to serialize an EMF model represented by an
>> XtestResource to XMI? I really would like to use Xtext in order to
>> describe my ecore models in a textual way but still store it as XMI (or
>> as a text file depending on the user). Do I need to write a custom
>> Serializer in order to achieve that?
>>
>> Regards,
>> Thomas.
|
|
|
Re: XtextResource to XMI [message #62948 is a reply to message #62946] |
Thu, 23 July 2009 19:42 ![Go to previous message Go to previous message](theme/Solstice/images/up.png) ![Go to next message Go to next message](theme/Solstice/images/down.png) |
Sebastian Zarnekow![Friend of Eclipse Friend](/donate/web-api/friends_decorator.php?email=sebastian.zarnekow%40gmail.com) Messages: 3118 Registered: July 2009 |
Senior Member |
|
|
Hi Thomas,
from the usage of an IResource, I assume you are executing your code
inside of Eclipse. All you need to do to instantiate a resource, is to
create a resource set and use #getResource(URI).
XtextResourceSet set = new XtextResourceSet();
return set.getResource(.., true);
Xtext used EMF and google guice to do some difficult stuff, like
injecting the parser or finding the right resource factory for your file
extension.
Hope that helps,
Sebastian
--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com
Am 23.07.2009 20:24 Uhr, schrieb Thomas:
> Hi,
>
> where do I get the XtextResource instance from? I tried the following in
> the UI-plugin but did not succeed:
>
> private XtextResource
> getXtextResource(org.eclipse.core.ressources.IResource resource) throws
> IOException{
> XtextResource xtextRes = new XtextResource();
> xtextRes.load(new FileInputStream(resource.getLocation.toFile()), new
> HashMap<String,String>());
> return xtextRes;
> }
>
> The problem is that the parser is not injected into the XtextResource
> which results in a NullPointerException in the "doLoad" method.
>
> Do you have a hint for me?
>
> Regards,
> Thomas.
>
> "Sebastian Zarnekow" <Sebastian.Zarnekow@itemis.de> wrote in message
> news:h47qlu$k27$2@build.eclipse.org...
>> Hi Thomas,
>>
>> something like this should work:
>>
>> XtextResource xtextRes = ...;
>> XmiResource xmiRes = new XmiResourceFactoryImpl().createResource(..);
>> xmiRes.getContents().add(xtextRes.getContents().get(0));
>> xmiRes.save(..);
>>
>> Hope that helps,
>> Sebastian
>>
>> --
>> Need professional support for Eclipse Modeling?
>> Go visit: http://xtext.itemis.com
>>
>> Am 22.07.2009 18:50 Uhr, schrieb Thomas:
>>> Hi,
>>>
>>> Is there an easy way to serialize an EMF model represented by an
>>> XtestResource to XMI? I really would like to use Xtext in order to
>>> describe my ecore models in a textual way but still store it as XMI (or
>>> as a text file depending on the user). Do I need to write a custom
>>> Serializer in order to achieve that?
>>>
>>> Regards,
>>> Thomas.
>
|
|
|
Re: XtextResource to XMI [message #62988 is a reply to message #62948] |
Fri, 24 July 2009 13:31 ![Go to previous message Go to previous message](theme/Solstice/images/up.png) |
Eclipse User![Friend of Eclipse Friend](/donate/web-api/friends_decorator.php?email=) |
|
|
|
Originally posted by: panajotes.gmx.de
Great, that did the trick.
Thanks,
Thomas.
"Sebastian Zarnekow" <Sebastian.Zarnekow@itemis.de> wrote in message
news:h4aefo$mpa$1@build.eclipse.org...
> Hi Thomas,
>
> from the usage of an IResource, I assume you are executing your code
> inside of Eclipse. All you need to do to instantiate a resource, is to
> create a resource set and use #getResource(URI).
>
> XtextResourceSet set = new XtextResourceSet();
> return set.getResource(.., true);
>
> Xtext used EMF and google guice to do some difficult stuff, like injecting
> the parser or finding the right resource factory for your file extension.
>
> Hope that helps,
> Sebastian
>
> --
> Need professional support for Eclipse Modeling?
> Go visit: http://xtext.itemis.com
>
> Am 23.07.2009 20:24 Uhr, schrieb Thomas:
>> Hi,
>>
>> where do I get the XtextResource instance from? I tried the following in
>> the UI-plugin but did not succeed:
>>
>> private XtextResource
>> getXtextResource(org.eclipse.core.ressources.IResource resource) throws
>> IOException{
>> XtextResource xtextRes = new XtextResource();
>> xtextRes.load(new FileInputStream(resource.getLocation.toFile()), new
>> HashMap<String,String>());
>> return xtextRes;
>> }
>>
>> The problem is that the parser is not injected into the XtextResource
>> which results in a NullPointerException in the "doLoad" method.
>>
>> Do you have a hint for me?
>>
>> Regards,
>> Thomas.
>>
>> "Sebastian Zarnekow" <Sebastian.Zarnekow@itemis.de> wrote in message
>> news:h47qlu$k27$2@build.eclipse.org...
>>> Hi Thomas,
>>>
>>> something like this should work:
>>>
>>> XtextResource xtextRes = ...;
>>> XmiResource xmiRes = new XmiResourceFactoryImpl().createResource(..);
>>> xmiRes.getContents().add(xtextRes.getContents().get(0));
>>> xmiRes.save(..);
>>>
>>> Hope that helps,
>>> Sebastian
>>>
>>> --
>>> Need professional support for Eclipse Modeling?
>>> Go visit: http://xtext.itemis.com
>>>
>>> Am 22.07.2009 18:50 Uhr, schrieb Thomas:
>>>> Hi,
>>>>
>>>> Is there an easy way to serialize an EMF model represented by an
>>>> XtestResource to XMI? I really would like to use Xtext in order to
>>>> describe my ecore models in a textual way but still store it as XMI (or
>>>> as a text file depending on the user). Do I need to write a custom
>>>> Serializer in order to achieve that?
>>>>
>>>> Regards,
>>>> Thomas.
>>
>
>
|
|
|
Goto Forum:
Current Time: Wed Aug 28 02:29:08 GMT 2024
Powered by FUDForum. Page generated in 0.04091 seconds
|