Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Can't serialize model with boolean attribute
Can't serialize model with boolean attribute [message #724850] Tue, 13 September 2011 10:40 Go to next message
Mirko Seifert is currently offline Mirko SeifertFriend
Messages: 31
Registered: July 2009
Member
Hi,

I've got a metaclass with a boolean attribute 'primary'. When I create a
model in memory and try to serialize it using resource.save(), the Xtext
serialzer complains that the attribute is not set.

The respective parser rule is:

MyMetaclass:
primary?='primary'
'MyMetaclass'
name=EString
;

In fact the attribute is set (to 'false') and I since the type of the
attribute is EBoolean there is IMHO no way the attribute can be not set.
It's either true or false, but never null.

I've tried to change the cardinality from 1..1 to 0..1 and to set the
attribute to transient, but I had no luck with that. I've also tried to
turn the validation off using the SaveOptions, but the result is the
same (serializer complains that the attribute is not set).

How can I serialize such models?

Thanks a lot in advance!

Best regards,

Mirko
Re: Can't serialize model with boolean attribute [message #724882 is a reply to message #724850] Tue, 13 September 2011 12:01 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3118
Registered: July 2009
Senior Member
Hi Mirko,

the boolean attribute 'primary' is mandatory in your grammar thus the
instance has to have a value #isPrimary == true.

Please try

MyMetaclass:
( primary?='primary' )?
'MyMetaclass'
name=EString
;

instead.

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

On 13.09.11 12:40, Mirko Seifert wrote:
> MyMetaclass:
> primary?='primary'
> 'MyMetaclass'
> name=EString
> ;
Re: Can't serialize model with boolean attribute [message #724883 is a reply to message #724882] Tue, 13 September 2011 12:03 Go to previous message
Mirko Seifert is currently offline Mirko SeifertFriend
Messages: 31
Registered: July 2009
Member
Hi Sebastian,

thanks, that did the trick!

Best regards,

Mirko


On 13.09.2011 14:01, Sebastian Zarnekow wrote:
> Hi Mirko,
>
> the boolean attribute 'primary' is mandatory in your grammar thus the
> instance has to have a value #isPrimary == true.
>
> Please try
>
> MyMetaclass:
> ( primary?='primary' )?
> 'MyMetaclass'
> name=EString
> ;
>
> instead.
>
> Regards,
> Sebastian
Previous Topic:Keyword Conflict
Next Topic:Strange errors using Xtext in a plugin
Goto Forum:
  


Current Time: Thu Apr 25 01:22:32 GMT 2024

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

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

Back to the top