Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Serialization format
Serialization format [message #775549] Fri, 06 January 2012 08:53 Go to next message
Jeff MAURY is currently offline Jeff MAURYFriend
Messages: 44
Registered: July 2009
Member
I intend to use Xtext to build an editor for an XML format. So what I did is create an ecore model from the XML Schema, then create an XText project from this ecore model.
I had some strange things in the Xtext grammar (but this is not the purpose of this topic).
My question is: the format of the resource is a kind of "groovy" like DSL, but it is possible to handle serialization so that the file is stored and retrieved as XML ?

Thanks
Jeff
Re: Serialization format [message #775553 is a reply to message #775549] Fri, 06 January 2012 09:04 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
Jeff,

Yes, you can read and write XML using EMFs generated
XyzResourceFactoryImpl which produces a derived XMLResourceImpl
configured to respect your XML Schema. To read and write your DSL,
you'll need to use the Xtext generated resource factory's resource. To
convert between the two, you'd have to move or copy the instance between
the resource implementations.


On 06/01/2012 9:53 AM, Jeff MAURY wrote:
> I intend to use Xtext to build an editor for an XML format. So what I
> did is create an ecore model from the XML Schema, then create an XText
> project from this ecore model.
> I had some strange things in the Xtext grammar (but this is not the
> purpose of this topic).
> My question is: the format of the resource is a kind of "groovy" like
> DSL, but it is possible to handle serialization so that the file is
> stored and retrieved as XML ?
>
> Thanks
> Jeff
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Serialization format [message #775560 is a reply to message #775553] Fri, 06 January 2012 09:21 Go to previous messageGo to next message
Jeff MAURY is currently offline Jeff MAURYFriend
Messages: 44
Registered: July 2009
Member
Thanks for your reply. My question was much related to the Xtext editor. Is it possible that the loading and writing of the resource can be hooked so that the conversion from/to XML is done as you said, so that the resource is always XML ?
Re: Serialization format [message #775567 is a reply to message #775560] Fri, 06 January 2012 09:30 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
Jeff,

That sounds trickier. You want to display the source DSL syntax to the
user, but whenever you save or load, you want the actual serialized
representation to be XML? I imagine that's possible, but you'd
definitely need to fuss with there being two resources implementations
and copying the contained instances between those resources. I.e., for
loading, you'd need to load with the XML resource impl and then
copy/move the contents to an Xtext-based resource implementation;I'm not
sure the serializer is invoked automatically to produce the node model
Xtext needs, but that's certainly supported and feasible. Then when you
save, you'd need to copy the contents back to the XML resource impl and
save that instead. With some effort, I sure that would all be
possible. But the devil is in the details. I wonder if anyone else has
tried this. (It would be interesting to support this possibility for
Xcore.)


On 06/01/2012 10:21 AM, Jeff MAURY wrote:
> Thanks for your reply. My question was much related to the Xtext
> editor. Is it possible that the loading and writing of the resource
> can be hooked so that the conversion from/to XML is done as you said,
> so that the resource is always XML ?


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Serialization format [message #775568 is a reply to message #775567] Fri, 06 January 2012 09:33 Go to previous messageGo to next message
Jeff MAURY is currently offline Jeff MAURYFriend
Messages: 44
Registered: July 2009
Member
That's exaclty what I want to achieve. I will let you know if I found a solution
Re: Serialization format [message #775587 is a reply to message #775568] Fri, 06 January 2012 10:06 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3118
Registered: July 2009
Senior Member
Hi Jeff,

OCL has a similar solution for editing ecore files with a nicer textual
notation but still storing them as *.ecore. Maybe you want to look into
that one.

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

Am 06.01.12 10:33, schrieb Jeff MAURY:
> That's exaclty what I want to achieve. I will let you know if I found a
> solution
Re: Serialization format [message #775625 is a reply to message #775587] Fri, 06 January 2012 11:47 Go to previous message
Jeff MAURY is currently offline Jeff MAURYFriend
Messages: 44
Registered: July 2009
Member
Thanks, I will have a look at OCL
Previous Topic:Questions regarding tutorial and Problems with generating Code
Next Topic:designing grammar for correct scoping context
Goto Forum:
  


Current Time: Thu Apr 25 11:42:34 GMT 2024

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

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

Back to the top