Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Turning EMF into XML/XMI without using a resource
Turning EMF into XML/XMI without using a resource [message #523935] Mon, 29 March 2010 21:37 Go to next message
Stephen McCants is currently offline Stephen McCantsFriend
Messages: 92
Registered: July 2009
Member
I have EMF objects in a resource set that stores the resources in a database. I want to be able to
turn those EMF objects into XML to pass them to other applications in XML/XMI format. However,
since they are not stored as XML, I need to convert them. I can copy them into a XMIResourceSet and
use that, but that means I have two resource sets holding identical data. Is there anyway to
avoid that and turn EMF objects directly into XML? Thanks.

--Stephen
Re: Turning EMF into XML/XMI without using a resource [message #523941 is a reply to message #523935] Mon, 29 March 2010 22:43 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
Stephen,

Comments below.

Stephen McCants wrote:
> I have EMF objects in a resource set that stores the resources in a
> database. I want to be able to turn those EMF objects into XML to
> pass them to other applications in XML/XMI format. However, since
> they are not stored as XML, I need to convert them. I can copy them
> into a XMIResourceSet and use that, but that means I have two
> resource sets holding identical data. Is there anyway to avoid that
> and turn EMF objects directly into XML?
You could copy it, put it in a resource that's not in the resource set,
and then let it all be garbage collected when it's done.
> Thanks.
>
> --Stephen


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Turning EMF into XML/XMI without using a resource [message #524047 is a reply to message #523941] Tue, 30 March 2010 13:05 Go to previous message
Jonas Helming is currently offline Jonas HelmingFriend
Messages: 699
Registered: July 2009
Senior Member
I do it like this:
First copy the root element of the subtree you want to export:

newResource.getContents().add(copyOfRoot);
ByteArrayOutputStream out = new ByteArrayOutputStream();
try {
newResource.save(out, null);
} catch (IOException e) {
throw new WhatEverException("Something wrong", e);
}
Ed Merks wrote:
> Stephen,
>
> Comments below.
>
> Stephen McCants wrote:
>> I have EMF objects in a resource set that stores the resources in a
>> database. I want to be able to turn those EMF objects into XML to
>> pass them to other applications in XML/XMI format. However, since
>> they are not stored as XML, I need to convert them. I can copy them
>> into a XMIResourceSet and use that, but that means I have two
>> resource sets holding identical data. Is there anyway to avoid that
>> and turn EMF objects directly into XML?
> You could copy it, put it in a resource that's not in the resource set,
> and then let it all be garbage collected when it's done.
>> Thanks.
>>
>> --Stephen
Previous Topic:Very Big Model
Next Topic:Can I override/specialize an EFeature in a subclass?
Goto Forum:
  


Current Time: Wed Apr 24 19:11:39 GMT 2024

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

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

Back to the top