Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Save Resource Without Alphabetic Sorting
Save Resource Without Alphabetic Sorting [message #1830603] Wed, 29 July 2020 15:55 Go to next message
Hadeer Tarek is currently offline Hadeer TarekFriend
Messages: 1
Registered: July 2020
Junior Member
Hello,

I am working on a project that uses emf.ecore.resource to read and write arxml files.

sample arxml file:
<parent>
<general/>
<config/>
</parent>

The file is read in its normal order but when saving it again, the containers are sorted alphabetically as shown:
<parent>
<config/>
<general/>
</parent>

I want to keep the order as it is.

Sample from my code for saving:

Map<String, Object> options = new HashMap<String, Object>();
options.put("ENCODING", "UTF-8"); options.put(ExtendedResource.OPTION_RESOURCE_VERSION_DESCRIPTOR,Autosar40ResourceFactoryImpl.AUTOSAR_4_0_3_RESOURCE_DESCRIPTOR);
OutputStream outStream = new FileOutputStream(new File("hadeer.arxml"));
ar.getResources().get(1).save(outStream, options);
outStream.close();

--
Kind Regards
Re: Save Resource Without Alphabetic Sorting [message #1830614 is a reply to message #1830603] Wed, 29 July 2020 19:43 Go to previous message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7098
Registered: July 2009
Senior Member
HI

My recollection is that they are no sorted, rather they are in declaration order in the Ecore model, which you could reorder to taste, except that you don't want to change things.

Real EMF experts can work wonders with the ExtendedMetaData, so maybe that can help.

I would be inclined to ensure that you define a BetterResourceImpl for your Better model, and do an in-memory 'sort' into your preferred order as part of the save activity. If necessary cache the old order so that you can revert in-memory afterwards.

Regards

Ed Willink
Previous Topic:Getting EObject from an URI
Next Topic:Extending a metamodel without overriding it
Goto Forum:
  


Current Time: Fri Apr 16 03:52:31 GMT 2021

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

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

Back to the top