Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Compare » NLP on comparing two xml files(NLP on comparing two xml files using XsdEcoreBuilder)
NLP on comparing two xml files [message #1696278] Mon, 25 May 2015 08:36
Rajkumar K is currently offline Rajkumar KFriend
Messages: 26
Registered: May 2015
Junior Member
I need to compare two xml files i.e lower version and upper version. The source xml

and target xml file have different version of Meta-Model schema. I am using

XsdEcorebuilder to convert my XSD to ECore and adding to the resourseSet. I have

also loaded my xml in the resourseSet. Later when I compare my model of two xml

files EMFcompare model throws NLP exception. Let me know why the featureID is

null for DynamicEObjectImpl ?

Do I need to explicitly add the factory instance to the resourceSet ?

Snippets.

XSDEcoreBuilder xsdEcoreBuilder = new XSDEcoreBuilder();
ResourceSet versionLowerset = new ResourceSetImpl();
versionLowerset.getResourceFactoryRegistry().getExtensionToFactoryMap().put("ecore", new EcoreResourceFactoryImpl());
versionLowerset.getResourceFactoryRegistry().getExtensionToFactoryMap().put("xml", new GenericXMLResourceFactoryImpl());
Collection eCorePackages = xsdEcoreBuilder.generate(versionLowerschemaURI);
for (Iterator iter = eCorePackages.iterator(); iter.hasNext()Wink {
EPackage element = (EPackage) iter.next();
versionLowerset.getPackageRegistry().put("mymodel.org/schema/v2.0", element);
}

Resource lowerVersionResource = versionLowerset.createResource(fileURISource);
Map options = new HashMap();
options.put(XMLResource.OPTION_EXTENDED_META_DATA, Boolean.TRUE);
options.put(XMLResource.OPTION_SCHEMA_LOCATION, Boolean.TRUE);
lowerVersionResource.load(options);

XSDEcoreBuilder upperVersionXsdEcoreBuilder = new XSDEcoreBuilder();

ResourceSet upperVersionSet = new ResourceSetImpl();
upperVersionSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("ecore", new EcoreResourceFactoryImpl());
upperVersionSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("xml", new GenericXMLResourceFactoryImpl());
Collection upperVersionPackages = upperVersionXsdEcoreBuilder.generate(versionUpperchemaURI);
for (Iterator iter = upperVersionPackages.iterator(); iter.hasNext()Wink {
EPackage element = (EPackage) iter.next();
upperVersionSet.getPackageRegistry().put("mymodel.org/schema/v2.0", element);
}

Resource upperVersionResource = upperVersionSet.createResource(fileURITarget);
Map options1 = new HashMap();
options1.put(XMLResource.OPTION_EXTENDED_META_DATA, Boolean.TRUE);
options1.put(XMLResource.OPTION_SCHEMA_LOCATION, Boolean.TRUE);
upperVersionResource.load(options1);

EObject myObject = lowerVersionResource.getContents().get(0);
EObject myObject1 = upperVersionResource.getContents().get(0);

// Configure EMF Compare
EMFCompare comparator = EMFCompare.builder().build();

// Compare the two models
IComparisonScope scope = EMFCompare.createDefaultScope(myObject, myObject1);
Comparison compare = comparator.compare(scope); // throws NLP

Java.lang.NullPointerException
at org.eclipse.emf.ecore.impl.EClassImpl.getFeatureID(EClassImpl.java:1495)
at org.eclipse.emf.ecore.impl.DynamicEObjectImpl.eDerivedStructuralFeatureID(DynamicEObjectImpl.java:218)
at org.eclipse.emf.ecore.impl.BasicEObjectImpl.eGet(BasicEObjectImpl.java:1008)
at org.eclipse.emf.ecore.impl.BasicEObjectImpl.eGet(BasicEObjectImpl.java:1003)
at org.eclipse.emf.compare.utils.ReferenceUtil.safeEGet(ReferenceUtil.java:92)
at org.eclipse.emf.compare.diff.DefaultDiffEngine.computeSingleValuedAttributeDifferences(DefaultDiffEngine.java:706)
at org.eclipse.emf.compare.diff.DefaultDiffEngine.computeDifferences(DefaultDiffEngine.java:497)
at org.eclipse.emf.compare.match.eobject.EditionDistance$CountingDiffEngine.computeDifferences(EditionDistance.java:382)
at org.eclipse.emf.compare.diff.DefaultDiffEngine.checkForDifferences(DefaultDiffEngine.java:130)
at org.eclipse.emf.compare.match.eobject.EditionDistance$CountingDiffEngine.measureDifferences(EditionDistance.java:427)
at org.eclipse.emf.compare.match.eobject.EditionDistance.distance(EditionDistance.java:155)
at org.eclipse.emf.compare.match.eobject.internal.CachingDistance.distance(CachingDistance.java:57)
at org.eclipse.emf.compare.match.eobject.internal.ProximityIndex.findTheClosest(ProximityIndex.java:182)
at org.eclipse.emf.compare.match.eobject.internal.ProximityIndex.findTheClosest(ProximityIndex.java:196)
at org.eclipse.emf.compare.match.eobject.internal.ProximityIndex.findClosests(ProximityIndex.java:110)
at org.eclipse.emf.compare.match.eobject.internal.ByTypeIndex.findClosests(ByTypeIndex.java:86)
at org.eclipse.emf.compare.match.eobject.ProximityEObjectMatcher.tryToMatch(ProximityEObjectMatcher.java:276)
at org.eclipse.emf.compare.match.eobject.ProximityEObjectMatcher.matchList(ProximityEObjectMatcher.java:233)
at org.eclipse.emf.compare.match.eobject.ProximityEObjectMatcher.matchIndexedObjects(ProximityEObjectMatcher.java:164)
at org.eclipse.emf.compare.match.eobject.ProximityEObjectMatcher.createMatches(ProximityEObjectMatcher.java:128)
at org.eclipse.emf.compare.match.eobject.IdentifierEObjectMatcher.doDelegation(IdentifierEObjectMatcher.java:153)
at org.eclipse.emf.compare.match.eobject.IdentifierEObjectMatcher.createMatches(IdentifierEObjectMatcher.java:116)
at org.eclipse.emf.compare.match.DefaultMatchEngine.match(DefaultMatchEngine.java:312)
at org.eclipse.emf.compare.match.DefaultMatchEngine.match(DefaultMatchEngine.java:121)
at org.eclipse.emf.compare.match.DefaultMatchEngine.match(DefaultMatchEngine.java:91)
at org.eclipse.emf.compare.EMFCompare.compare(EMFCompare.java:163)
at org.eclipse.emf.compare.EMFCompare.compare(EMFCompare.java:146)
at com.xyz.tests.testCompare(CompareTest.java:198)
Previous Topic:ignoring identifiers problem
Next Topic:Problem with merge: duplicate objects are created
Goto Forum:
  


Current Time: Fri Sep 21 17:36:39 GMT 2018

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

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

Back to the top