Skip to main content



      Home
Home » Modeling » TMF (Xtext) » transform model in XMI to xtext model
transform model in XMI to xtext model [message #531059] Mon, 03 May 2010 10:38 Go to next message
Eclipse UserFriend
Hi guys,

I have build the textual DSL, and I know the code to transform the textual DSL file to XMI. However, how to transform the XMI model back to textual DSL? Any advice?

Thanks.

Yu
Re: transform model in XMI to xtext model [message #531066 is a reply to message #531059] Mon, 03 May 2010 11:13 Go to previous messageGo to next message
Eclipse UserFriend
Hello Yu,

have a look at http://www.eclipse.org/Xtext/documentation/0_7_2/xtext.html# serialization. Just add the Contents of your XMI resource to a Xtext resource and call save (just the other way round than creating the xmi)

~Christian
Re: transform model in XMI to xtext model [message #531071 is a reply to message #531066] Mon, 03 May 2010 11:30 Go to previous messageGo to next message
Eclipse UserFriend
I got it. Thanks a lot Christian.
Re: transform model in XMI to xtext model [message #531160 is a reply to message #531071] Mon, 03 May 2010 19:38 Go to previous messageGo to next message
Eclipse UserFriend
Hi guys,

I have made the transformation from XMI to xtext working. However, there is one interesting problem:

In my xtext, I defined my own SHORT type, which is:

terminal SHORT returns ecore:Eshort :
    INT's'
;


I also defined my own TerminalConverters to get the short value by removing the last 's'. It works perfect, and transforming the xtext file to XMI model also works fine.

However, now when I transform the XMI model back to xtext file, the short values in the xtext file does not contain the 's', which is not a correct xtext file in my grammar.

Is there anything I can do to solve this problem?

Thanks a lot.

Yu

[Updated on: Mon, 03 May 2010 19:39] by Moderator

Re: transform model in XMI to xtext model [message #531201 is a reply to message #531160] Tue, 04 May 2010 03:44 Go to previous messageGo to next message
Eclipse UserFriend
Hi Yu,

please override the toString(Value) method in your value converter
implementation that removes the 's' from the parsed input. The
toString() should add it as it is required in the concrete syntax.

Regards,
Sebastian
--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com

Am 04.05.10 01:38, schrieb Yu Sun:
> Hi guys,
>
> I have made the transformation from XMI to xtext working. However, there
> is one interesting problem:
>
> In my xtext, I defined my own SHORT type, which is:
>
> <CODE>
> terminal SHORT returns ecore:Eshort :
> INT's'
> ;
> </CODE>
>
> I also defined my own TerminalConverters to get the short value by
> removing the last 's'. It works perfect, and transforming the xtext file
> to XMI model also works fine.
>
> However, now when I transform the XMI model back to xtext file, the
> short values in the xtext file does not contain the 's', which is not a
> correct xtext file in my grammar.
>
> Is there anything I can do to solve this problem?
>
> Thanks a lot.
>
> Yu
>
>
Re: transform model in XMI to xtext model [message #531304 is a reply to message #531201] Tue, 04 May 2010 09:50 Go to previous messageGo to next message
Eclipse UserFriend
Thanks Sebastian. That works!

Another question about this part is that the textual dsl file being transformed from XMI model do not have line separators and indent.

I guess that the only way to realize this is to add line separators into the grammar, right?

Sorry for so many questions. I really appreciate all your help.

Yu
Re: transform model in XMI to xtext model [message #531312 is a reply to message #531304] Tue, 04 May 2010 10:16 Go to previous messageGo to next message
Eclipse UserFriend
Hello Yu,

for whitespace handling you can implement a formatter as described in http://www.eclipse.org/Xtext/documentation/0_7_2/xtext.html# formatting

~Christian
Re: transform model in XMI to xtext model [message #531393 is a reply to message #531312] Tue, 04 May 2010 13:26 Go to previous message
Eclipse UserFriend
Thank you so much, Christian.
Previous Topic:a grammar design question
Next Topic:configureImportantInformation gone in 1.0 nightly?
Goto Forum:
  


Current Time: Fri Jul 04 11:48:33 EDT 2025

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

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

Back to the top