Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Is it possible to save more than one object in one resource?(XmlResource only serializes one (first) content)
Is it possible to save more than one object in one resource? [message #513248] Tue, 09 February 2010 13:57 Go to next message
Jens Dürr is currently offline Jens DürrFriend
Messages: 7
Registered: January 2010
Junior Member
Hi all,

I'm trying to save more than one model object in one resource, but only the first added content gets serialized.

The model is genereated from xml schema, so the used resource is a subclass of XmlResource.

After reading the docs I thought this should be possible.

Greetings Jens
Re: Is it possible to save more than one object in one resource? [message #513250 is a reply to message #513248] Tue, 09 February 2010 14:05 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Not at the root because XML-Files can only hold one Object as
Root-Element. An XML-File like this is invalid:

<?xml version='1.0'>
<test></test>
<test></test>

Tom

Am 09.02.10 14:57, schrieb Jens Dürr:
> Hi all,
>
> I'm trying to save more than one model object in one resource, but only
> the first added content gets serialized.
>
> The model is genereated from xml schema, so the used resource is a
> subclass of XmlResource.
>
> After reading the docs I thought this should be possible.
>
> Greetings Jens
Re: Is it possible to save more than one object in one resource? [message #513251 is a reply to message #513250] Tue, 09 February 2010 14:09 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33141
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------090301060003020405010606
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit

Tom,

Exactly. For this reason it's only possible with XMIResourceImpl; in
that case, when there are multiple roots, a "fake" XMI root element is
used to hold them.


Tom Schindl wrote:
> Not at the root because XML-Files can only hold one Object as
> Root-Element. An XML-File like this is invalid:
>
> <?xml version='1.0'>
> <test></test>
> <test></test>
>
> Tom
>
> Am 09.02.10 14:57, schrieb Jens Dürr:
>
>> Hi all,
>>
>> I'm trying to save more than one model object in one resource, but only
>> the first added content gets serialized.
>>
>> The model is genereated from xml schema, so the used resource is a
>> subclass of XmlResource.
>>
>> After reading the docs I thought this should be possible.
>>
>> Greetings Jens
>>
>
>

--------------090301060003020405010606
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 8bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=UTF-8" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Tom,<br>
<br>
Exactly.  For this reason it's only possible with XMIResourceImpl; in
that case, when there are multiple roots, a "fake" XMI root element is
used to hold them.<br>
<br>
<br>
Tom Schindl wrote:
<blockquote cite="mid:hkrq39$gds$1@build.eclipse.org" type="cite">
<pre wrap="">Not at the root because XML-Files can only hold one Object as
Root-Element. An XML-File like this is invalid:

&lt;?xml version='1.0'&gt;
&lt;test&gt;&lt;/test&gt;
&lt;test&gt;&lt;/test&gt;

Tom

Am 09.02.10 14:57, schrieb Jens Dürr:
</pre>
<blockquote type="cite">
<pre wrap="">Hi all,

I'm trying to save more than one model object in one resource, but only
the first added content gets serialized.

The model is genereated from xml schema, so the used resource is a
subclass of XmlResource.

After reading the docs I thought this should be possible.

Greetings Jens
</pre>
</blockquote>
<pre wrap=""><!---->
</pre>
</blockquote>
</body>
</html>

--------------090301060003020405010606--


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Is it possible to save more than one object in one resource? [message #513262 is a reply to message #513251] Tue, 09 February 2010 14:56 Go to previous messageGo to next message
Jens Dürr is currently offline Jens DürrFriend
Messages: 7
Registered: January 2010
Junior Member
Sure! It is quite obvious that there can only be one root per xml document. That's something I could have figure out by myself Smile

Is it possible to somehow mix in XMIResourceImpl to get this "fake" root element?

Jens
Re: Is it possible to save more than one object in one resource? [message #513273 is a reply to message #513262] Tue, 09 February 2010 15:32 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33141
Registered: July 2009
Senior Member
Jens,

You can change the GenPackage's Resource Type property to XMI. Of
course the resulting serialization won't conform to your schema...


Jens Dürr wrote:
> Sure! It is quite obvious that there can only be one root per xml
> document. That's something I could have figure out by myself :)
>
> Is it possible to somehow mix in XMIResourceImpl to get this "fake"
> root element?
>
> Jens


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Is it possible to save more than one object in one resource? [message #514378 is a reply to message #513273] Mon, 15 February 2010 06:57 Go to previous messageGo to next message
Petr Kalafatic is currently offline Petr KalafaticFriend
Messages: 10
Registered: July 2009
Junior Member
Hi,
I have similar problem.
I have one main data model (feature A)
and second model (feature B) is used just for adding objects to main model (both are loaded from one resource)
Features must be independent-they just know the path to the real model file (no dependency between plugins).
Any idea to solve it in other way ?
Thank you,
Petr
Re: Is it possible to save more than one object in one resource? [message #514444 is a reply to message #514378] Mon, 15 February 2010 11:31 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33141
Registered: July 2009
Senior Member
Petr,

Comments below.

Petr Kalafatic wrote:
> Hi,
> I have similar problem.
> I have one main data model (feature A)
> and second model (feature B) is used just for adding objects to main
> model (both are loaded from one resource)
> Features must be independent-they just know the path to the real model
> file (no dependency between plugins).
> Any idea to solve it in other way ?
You're trying to put both objects in one resource? Either you put them
both at the root, and then you can't use XMLResourceImpl, or you create
a container object that's able to hold both and you put that one
container at the root of the resource.
> Thank you,
> Petr


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:[CDO] Transaction Exception
Next Topic:Re: model/TreeView synchronization problem.
Goto Forum:
  


Current Time: Fri Apr 26 06:24:36 GMT 2024

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

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

Back to the top