compare two xml models? [message #925245] |
Thu, 27 September 2012 10:28  |
Eclipse User |
|
|
|
Hi,
Can someone give show me a code sample to compare two xml models? I need to look into, how to compare two xml models using EMF compare programatically.
Thanks
K
|
|
|
Re: compare two xml models? [message #926058 is a reply to message #925245] |
Fri, 28 September 2012 05:07   |
Eclipse User |
|
|
|
File file1 = new File("EMFModelA.ecore");
File file2 = new File("EMFModelB.ecore");
//register XMI resource factory for all other extensions
Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap(
).put(Resource.Factory.Registry.DEFAULT_EXTENSION,
new XMIResourceFactoryImpl());
ResourceSet resourceSet = new ResourceSetImpl();
//Loading resources
EObject model1 = ModelUtils.load(file1,resourceSet);
EObject model2 = ModelUtils.load(file2,resourceSet);
//matching models
// MatchModel match = MatchService.doMatch(model1, model2, Collections.<String, Object> emptyMap());
MatchModel match = MatchService.doContentMatch(model1, model2, Collections.<String, Object> emptyMap());
//matching engine and matching
GenericMatchEngine eng = new GenericMatchEngine();
match = eng.contentMatch(model1, model2, Collections.<String, Object> emptyMap());
//Differencing models
DiffModel diff = DiffService.doDiff(match);
Iterator<DiffElement> it = diff.getDifferences().iterator();
while (it.hasNext()){
System.out.println(it.next());
}
|
|
|
|
|
|
|
Re: compare two xml models? [message #1006632 is a reply to message #1006507] |
Fri, 01 February 2013 04:32  |
Eclipse User |
|
|
|
Pedro,
Please elaborate upon what you are trying to achieve.
All you should have to do is install the already built library. Whether you want EMF Compare to be usable to compare EMF models in your Eclipse, you want to develop an Eclipse plug-in that augments or makes use of EMF Compare or you wish to use EMF Compare from your standalone application.
Cloning the git repository containing the source code of EMF Compare is only necessary if you wish to develop patches or contributions to EMF Compare.
Follow the Installation instructions in order to install EMF Compare in Eclipse. Once done, the jars will simply be available to you. The will be located in your Eclipse "<installation directory>/plugins" folders ... but that is only relevant if you wish to develop a standalone application. Otherwise you'll never have to meddle with their location on disk.
Laurent Goubet
Obeo
|
|
|
Powered by
FUDForum. Page generated in 0.07468 seconds