Save Resource Without Alphabetic Sorting [message #1830603] |
Wed, 29 July 2020 11:55  |
Eclipse User |
|
|
|
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 15:43  |
Eclipse User |
|
|
|
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
|
|
|
Powered by
FUDForum. Page generated in 0.23182 seconds