Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Saving loaded contents to another file add cross document references
Saving loaded contents to another file add cross document references [message #881118] Sun, 03 June 2012 23:48 Go to next message
John M. is currently offline John M.Friend
Messages: 198
Registered: July 2010
Senior Member
Hello,

I load some resources with the ResourceSet.getResource(uri, true) and store the contents into a variable.
Now I want to save the contents to another file.
I have tried it with following code:
Resource resource = resourceSet.createResource(uri);
resource.getContents().add(contents);
resource.save(null);


It works good so far, but the system adds in front of reference the filename.
So <links source="#//@basemodel/@nodes.0" target="#//@basemodel/@nodes.1"> got <links source="/asdf/My1.container#//@basemodel/@nodes.0" target="/asdf/My1.container#//@basemodel/@nodes.1">.
Is there any possibility to prevent that behaviour?
Or is there a better way to copy the contents?
Re: Saving loaded contents to another file add cross document references [message #881175 is a reply to message #881118] Mon, 04 June 2012 03:51 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33137
Registered: July 2009
Senior Member
You might simply need to ensure that all the proxies are resolved before
you move the contents over, e.g., EcoreUtil.resolveAll(Resource).


On 04/06/2012 1:48 AM, Missing name Mising name wrote:
> Hello,
>
> I load some resources with the ResourceSet.getResource(uri, true) and
> store the contents into a variable.
> Now I want to save the contents to another file.
> I have tried it with following code:
>
> Resource resource = resourceSet.createResource(uri);
> resource.getContents().add(contents);
> resource.save(null);
>
>
> It works good so far, but the system adds in front of reference the
> filename.
> So <links source="#//@basemodel/@nodes.0"
> target="#//@basemodel/@nodes.1"> got <links
> source="/asdf/My1.container#//@basemodel/@nodes.0"
> target="/asdf/My1.container#//@basemodel/@nodes.1">.
> Is there any possibility to prevent that behaviour?
> Or is there a better way to copy the contents?


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Saving loaded contents to another file add cross document references [message #881297 is a reply to message #881175] Mon, 04 June 2012 09:51 Go to previous message
John M. is currently offline John M.Friend
Messages: 198
Registered: July 2010
Senior Member
Thanks for the hint. I found out, that there is internal a resource not found error, which produces the problem.
Using the absolute path fixed the problem.
Previous Topic:Creating a local stream for CDO development
Next Topic:[CDO/Hibernate/Teneo] org.hibernate.MappingException: Unknown entity: org.eclipse.emf.cdo.internal.c
Goto Forum:
  


Current Time: Sat Apr 20 01:01:01 GMT 2024

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

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

Back to the top