Can't serialize model with boolean attribute [message #724850] |
Tue, 13 September 2011 06:40  |
Eclipse User |
|
|
|
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 #724883 is a reply to message #724882] |
Tue, 13 September 2011 08:03  |
Eclipse User |
|
|
|
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
|
|
|
Powered by
FUDForum. Page generated in 0.07578 seconds