Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Empy many ereference is not serialized with empty content
Empy many ereference is not serialized with empty content [message #719690] Sun, 28 August 2011 12:37 Go to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi,
Using the Library example, if I serialize a writer without books then I get xml without the books attribute:
<?xml version="1.0" encoding="UTF-8"?>
<library:Writer xmlns:library="http://www.eclipse.org/emf/texo/test/model/samples/library" db_Id="3" name="1314534528278"/>

is there a way to force an empty books attribute in the xml? Does the same apply to EAttributes or non-many EFeatures?

My guess it is somehow related to unsettable, correct?

--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
Re: Empy many ereference is not serialized with empty content [message #719728 is a reply to message #719690] Sun, 28 August 2011 16:29 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33113
Registered: July 2009
Senior Member
Martin,

Multi-valued features can be made unsettable. To change the list's
default empty state to the set-to-empty state, you have to call clear()
on it.



On 28/08/2011 5:37 AM, Martin Taal wrote:
> Hi,
> Using the Library example, if I serialize a writer without books then
> I get xml without the books attribute:
> <?xml version="1.0" encoding="UTF-8"?>
> <library:Writer
> xmlns:library="http://www.eclipse.org/emf/texo/test/model/samples/library"
> db_Id="3" name="1314534528278"/>
>
> is there a way to force an empty books attribute in the xml? Does the
> same apply to EAttributes or non-many EFeatures?
>
> My guess it is somehow related to unsettable, correct?
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Empy many ereference is not serialized with empty content [message #719751 is a reply to message #719728] Sun, 28 August 2011 18:41 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Ed,
Hmm, I am now calling clear on the elist (EcoreList$Dynamic) but still the xml does not show an empty books tag. The
efeature has unsettable=false.

Is there another way to achieve this, or am I doing something wrong?

gr. Martin

On 08/28/2011 06:29 PM, Ed Merks wrote:
> Martin,
>
> Multi-valued features can be made unsettable. To change the list's default empty state to the set-to-empty state, you
> have to call clear() on it.
>
>
>
> On 28/08/2011 5:37 AM, Martin Taal wrote:
>> Hi,
>> Using the Library example, if I serialize a writer without books then I get xml without the books attribute:
>> <?xml version="1.0" encoding="UTF-8"?>
>> <library:Writer xmlns:library="http://www.eclipse.org/emf/texo/test/model/samples/library" db_Id="3"
>> name="1314534528278"/>
>>
>> is there a way to force an empty books attribute in the xml? Does the same apply to EAttributes or non-many EFeatures?
>>
>> My guess it is somehow related to unsettable, correct?
>>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
Re: Empy many ereference is not serialized with empty content [message #719752 is a reply to message #719751] Sun, 28 August 2011 19:04 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33113
Registered: July 2009
Senior Member
Martin,

Looking at XMLSaveImpl, it will only support this if the feature can be
saved as an XML attribute. Does it get to this logic in saveFeatures?

case OBJECT_CONTAIN_MANY_UNSETTABLE:
case DATATYPE_MANY:
{
if (isEmpty(o, f))
{
saveManyEmpty(o, f);
continue LOOP;
}
break;
}


On 28/08/2011 11:41 AM, Martin Taal wrote:
> Hi Ed,
> Hmm, I am now calling clear on the elist (EcoreList$Dynamic) but still
> the xml does not show an empty books tag. The efeature has
> unsettable=false.
>
> Is there another way to achieve this, or am I doing something wrong?
>
> gr. Martin
>
> On 08/28/2011 06:29 PM, Ed Merks wrote:
>> Martin,
>>
>> Multi-valued features can be made unsettable. To change the list's
>> default empty state to the set-to-empty state, you
>> have to call clear() on it.
>>
>>
>>
>> On 28/08/2011 5:37 AM, Martin Taal wrote:
>>> Hi,
>>> Using the Library example, if I serialize a writer without books
>>> then I get xml without the books attribute:
>>> <?xml version="1.0" encoding="UTF-8"?>
>>> <library:Writer
>>> xmlns:library="http://www.eclipse.org/emf/texo/test/model/samples/library"
>>> db_Id="3"
>>> name="1314534528278"/>
>>>
>>> is there a way to force an empty books attribute in the xml? Does
>>> the same apply to EAttributes or non-many EFeatures?
>>>
>>> My guess it is somehow related to unsettable, correct?
>>>
>
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Empy many ereference is not serialized with empty content [message #719755 is a reply to message #719752] Sun, 28 August 2011 19:40 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Yes for datatypes, I am looking at ereferences, but the code ends up here:
protected void saveEObjectMany(EObject o, EStructuralFeature f)
{
@SuppressWarnings("unchecked") InternalEList<? extends EObject> values = (InternalEList<? extends
EObject>)helper.getValue(o, f);

if (!values.isEmpty())
.....
}
}

The xml is only created if the values are not empty.

I have to find another solution.

gr. Martin

On 08/28/2011 09:04 PM, Ed Merks wrote:
> Martin,
>
> Looking at XMLSaveImpl, it will only support this if the feature can be saved as an XML attribute. Does it get to this
> logic in saveFeatures?
>
> case OBJECT_CONTAIN_MANY_UNSETTABLE:
> case DATATYPE_MANY:
> {
> if (isEmpty(o, f))
> {
> saveManyEmpty(o, f);
> continue LOOP;
> }
> break;
> }
>
>
> On 28/08/2011 11:41 AM, Martin Taal wrote:
>> Hi Ed,
>> Hmm, I am now calling clear on the elist (EcoreList$Dynamic) but still the xml does not show an empty books tag. The
>> efeature has unsettable=false.
>>
>> Is there another way to achieve this, or am I doing something wrong?
>>
>> gr. Martin
>>
>> On 08/28/2011 06:29 PM, Ed Merks wrote:
>>> Martin,
>>>
>>> Multi-valued features can be made unsettable. To change the list's default empty state to the set-to-empty state, you
>>> have to call clear() on it.
>>>
>>>
>>>
>>> On 28/08/2011 5:37 AM, Martin Taal wrote:
>>>> Hi,
>>>> Using the Library example, if I serialize a writer without books then I get xml without the books attribute:
>>>> <?xml version="1.0" encoding="UTF-8"?>
>>>> <library:Writer xmlns:library="http://www.eclipse.org/emf/texo/test/model/samples/library" db_Id="3"
>>>> name="1314534528278"/>
>>>>
>>>> is there a way to force an empty books attribute in the xml? Does the same apply to EAttributes or non-many EFeatures?
>>>>
>>>> My guess it is somehow related to unsettable, correct?
>>>>
>>
>>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
Previous Topic:EMF.Editor New Child & Commands
Next Topic:(no subject)
Goto Forum:
  


Current Time: Fri Mar 29 10:21:32 GMT 2024

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

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

Back to the top