I would like to develop a compare merge plugin based on EMF Copare able to compare 2 kind of files *.xml1 and *.xml2.
As the syntaxe of the files migth not be the same, i want to that files into a same metamodel and then compare the 2 models
which then would contain only the relevant data to be compared
As i am not experimented with EMF Compare i wonder how to do it.
Where should i implement the model transformation (load and save) so that it is well integrated with EMF Compare
EMF Compare works on EMF models : if you implement your transformation before calling EMF Compare with them, you won't have integration problems. Note that you do not have to save the models before feeding them to compare if you're using it programmatically.
Your issue, then, is how to transform the models beforehand. For that you'll have to determine exactly what you wish to do, and with what tool : Java, ATL, ... look at the model-to-model tools on Eclipse.
As my XML file are not matching all the same XSD, i would like to transform my XML with DOM parser and to populate my EMF model. It seems that the Model2Model tools need on one side an XSD and on the other side an ECORE. In my case i may not have the XSD.
Note that all my XML files are built with the same "design rules"
when an element is not a singleton (max cardinality > 1), it has an attribute @Name which allow me to identify it uniquely. In that case, i compare the element and its attributes having the same element name and the same attribute @Name value (independently of their order in the XML file)
when an element is a singleton, i use only the element name to match and compare the element and its attributes
<Channel Name="abc" attr1="tt"/>
<Channel Name="def" attr1="sds"/> --> (<Channel> is not a singleton because it has an attribute @Name: so in my compare engine, i compare the elements if they have the same element name and attribute name)
<Properties Default="Off" Clock="8"> --> (<Properties> is a singleton because it do not have @Name: so it will be compared against another element <Properties/>)
I understood that i should override load and save, but i do miss some detail or sample how to implement it.
Do you think it is the good approach ?
I'd say that your best bet would be to define a metamodel that can properly describe the data you have in both models instead of trying to strip irrelevant data. Or to convert one of the two to the metamodel of the other and compare these two files.
Whatever the case, you might want to ask on the EMF newsgroup whether someone already had such a need.