Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Suppressing document root but loosing name of top element.
Suppressing document root but loosing name of top element. [message #489536] Sun, 04 October 2009 15:36 Go to next message
Thomas Hallgren is currently offline Thomas HallgrenFriend
Messages: 3240
Registered: July 2009
Senior Member
Hi,
I have a DocumentRoot declared that references the top element of the document using a relationship with the name
'rmap'. Everything works as expected. The XML is serialized with a top element <rmap> and I can edit the model, save it,
and edit again.

I wanted to get rid of the DocumentRoot in my generated editor so I added the load option OPTION_SUPPRESS_DOCUMENT_ROOT
= true.

The editor loads correctly and the document root is no longer displayed. Nice. The problem however, is that when I
change something and then save the model, the name of the top element is changed. Instead of using the name 'rmap' I now
get the name of the type of that element. The type name is not the same as the element name so subsequent attempts to
load the model fails.

In some sense, I can understand why this happens. After all, it's the name of the relationship from the document root to
the topmost element that was used so when I suppress that, how can the serializer know what name it should use? Is there
some way to tell the serializer what the topmost element should be named?

If anyone has encountered this before and know what's missing, please help.

Regards,
Thomas Hallgren
Re: Suppressing document root but loosing name of top element. [message #489537 is a reply to message #489536] Sun, 04 October 2009 15:48 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33216
Registered: July 2009
Senior Member
Thomas,

Did you also use OPTION_ELEMENT_HANDLER? ElementHandlerImpl will likely
produce the correct result.


Thomas Hallgren wrote:
> Hi,
> I have a DocumentRoot declared that references the top element of the
> document using a relationship with the name 'rmap'. Everything works
> as expected. The XML is serialized with a top element <rmap> and I can
> edit the model, save it, and edit again.
>
> I wanted to get rid of the DocumentRoot in my generated editor so I
> added the load option OPTION_SUPPRESS_DOCUMENT_ROOT = true.
>
> The editor loads correctly and the document root is no longer
> displayed. Nice. The problem however, is that when I change something
> and then save the model, the name of the top element is changed.
> Instead of using the name 'rmap' I now get the name of the type of
> that element. The type name is not the same as the element name so
> subsequent attempts to load the model fails.
>
> In some sense, I can understand why this happens. After all, it's the
> name of the relationship from the document root to the topmost element
> that was used so when I suppress that, how can the serializer know
> what name it should use? Is there some way to tell the serializer what
> the topmost element should be named?
>
> If anyone has encountered this before and know what's missing, please
> help.
>
> Regards,
> Thomas Hallgren
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Suppressing document root but loosing name of top element. [message #489540 is a reply to message #489537] Sun, 04 October 2009 16:50 Go to previous messageGo to next message
Thomas Hallgren is currently offline Thomas HallgrenFriend
Messages: 3240
Registered: July 2009
Senior Member
Hi Ed,
Thanks. That helped. Not sure why though. What does the ElementHandlerImpl do in this case? Why isn't that the default
behavior? The documentation doesn't go into much detail.

Regards,
Thomas Hallgren



On 10/04/2009 05:48 PM, Ed Merks wrote:
> Thomas,
>
> Did you also use OPTION_ELEMENT_HANDLER? ElementHandlerImpl will likely
> produce the correct result.
>
>
> Thomas Hallgren wrote:
>> Hi,
>> I have a DocumentRoot declared that references the top element of the
>> document using a relationship with the name 'rmap'. Everything works
>> as expected. The XML is serialized with a top element <rmap> and I can
>> edit the model, save it, and edit again.
>>
>> I wanted to get rid of the DocumentRoot in my generated editor so I
>> added the load option OPTION_SUPPRESS_DOCUMENT_ROOT = true.
>>
>> The editor loads correctly and the document root is no longer
>> displayed. Nice. The problem however, is that when I change something
>> and then save the model, the name of the top element is changed.
>> Instead of using the name 'rmap' I now get the name of the type of
>> that element. The type name is not the same as the element name so
>> subsequent attempts to load the model fails.
>>
>> In some sense, I can understand why this happens. After all, it's the
>> name of the relationship from the document root to the topmost element
>> that was used so when I suppress that, how can the serializer know
>> what name it should use? Is there some way to tell the serializer what
>> the topmost element should be named?
>>
>> If anyone has encountered this before and know what's missing, please
>> help.
>>
>> Regards,
>> Thomas Hallgren
>>
Re: Suppressing document root but loosing name of top element. [message #489543 is a reply to message #489540] Sun, 04 October 2009 17:16 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33216
Registered: July 2009
Senior Member
Thomas,

It helps find a global element in the document root and from the type of
that element, it knows the type of object to create for the root object.


Thomas Hallgren wrote:
> Hi Ed,
> Thanks. That helped. Not sure why though. What does the
> ElementHandlerImpl do in this case? Why isn't that the default
> behavior? The documentation doesn't go into much detail.
>
> Regards,
> Thomas Hallgren
>
>
>
> On 10/04/2009 05:48 PM, Ed Merks wrote:
>> Thomas,
>>
>> Did you also use OPTION_ELEMENT_HANDLER? ElementHandlerImpl will likely
>> produce the correct result.
>>
>>
>> Thomas Hallgren wrote:
>>> Hi,
>>> I have a DocumentRoot declared that references the top element of the
>>> document using a relationship with the name 'rmap'. Everything works
>>> as expected. The XML is serialized with a top element <rmap> and I can
>>> edit the model, save it, and edit again.
>>>
>>> I wanted to get rid of the DocumentRoot in my generated editor so I
>>> added the load option OPTION_SUPPRESS_DOCUMENT_ROOT = true.
>>>
>>> The editor loads correctly and the document root is no longer
>>> displayed. Nice. The problem however, is that when I change something
>>> and then save the model, the name of the top element is changed.
>>> Instead of using the name 'rmap' I now get the name of the type of
>>> that element. The type name is not the same as the element name so
>>> subsequent attempts to load the model fails.
>>>
>>> In some sense, I can understand why this happens. After all, it's the
>>> name of the relationship from the document root to the topmost element
>>> that was used so when I suppress that, how can the serializer know
>>> what name it should use? Is there some way to tell the serializer what
>>> the topmost element should be named?
>>>
>>> If anyone has encountered this before and know what's missing, please
>>> help.
>>>
>>> Regards,
>>> Thomas Hallgren
>>>
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:[CDO] Transient references and views
Next Topic:Extending EMF Code Generator
Goto Forum:
  


Current Time: Fri Sep 20 21:44:31 GMT 2024

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

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

Back to the top