| Summary: | EObjectValidator creates error marker that didn't exist in 2.4.2 | ||
|---|---|---|---|
| Product: | [Modeling] EMF | Reporter: | Grant Taylor <gdtaylor> |
| Component: | Core | Assignee: | Ed Merks <Ed.Merks> |
| Status: | RESOLVED WONTFIX | QA Contact: | |
| Severity: | major | ||
| Priority: | P3 | ||
| Version: | unspecified | ||
| Target Milestone: | --- | ||
| Hardware: | PC | ||
| OS: | Windows XP | ||
| Whiteboard: | |||
A document root must have exactly one element that's populated. In our case, you can see that it is an EAttribute that is being validated. Are you saying that an EAttribute modeled on a document root must always be present as well? Note that our document does in fact have exactly one child element in the instance file, and in the model. Yes I can see it's the EAttribute presenting the mixed feature of a document root. It apparently has no features for which kind == ExtendedMetaData.ELEMENT_FEATURE. |
Build Identifier: org.eclipse.emf.ecore_2.6.0.v20100614-1136.jar In our product, we're migrating to a new Eclipse base. One of things that is changing is the org.eclipse.emf.ecore plugin, from 2.4.2 to 2.6.0. When our model validator runs, it calls EObjectValidator.validate_MultiplicityConforms() up the hierarchy. Our modeled attribute looks like this: org.eclipse.emf.ecore.impl.EAttributeImpl@10571057 (name: mixed) (ordered: true, unique: true, lowerBound: 0, upperBound: -1) (changeable: true, volatile: false, transient: false, defaultValueLiteral: null, unsettable: false, derived: false) (iD: false) The above is modeled against the document root of our model. With the new EMF level, I see an error coming out of the validator: "The feature 'mixed' of 'com.******.impl.DocumentRootImpl@1ff71ff7{platform:/resource/****/***.****#/}' with 0 element values must have exactly 1 element value" (note I replaced some characters with *'s) The above validation error doesn't make a lot of sense to me because the EAttribute is obviously modeled with 0...n cardinality. Debugging the two versions of our product, I can see that ObjectValidator.validate_MultiplicityConforms() has changed. There is a new block of code that creates the validation marker: ... boolean result = true; if (eStructuralFeature.isMany()) { if (FeatureMapUtil.isFeatureMap(eStructuralFeature) && ExtendedMetaData.INSTANCE.isDocumentRoot(eObject.eClass())) { FeatureMap featureMap = (FeatureMap)eObject.eGet(eStructuralFeature); int count = 0; for (int i = 0, size = featureMap.size(); i < size; ++i) { EStructuralFeature feature = featureMap.getEStructuralFeature(i); int kind = ExtendedMetaData.INSTANCE.getFeatureKind(feature); if (kind == ExtendedMetaData.ELEMENT_FEATURE && feature != XMLTypePackage.Literals.XML_TYPE_DOCUMENT_ROOT__CDATA && feature != XMLTypePackage.Literals.XML_TYPE_DOCUMENT_ROOT__COMMENT && feature != XMLTypePackage.Literals.XML_TYPE_DOCUMENT_ROOT__TEXT && feature != XMLTypePackage.Literals.XML_TYPE_DOCUMENT_ROOT__PROCESSING_INSTRUCTION && ++count > 1) { result = false; break; } } if (count != 1) { result = false; if (diagnostics != null) { diagnostics.add (createDiagnostic (Diagnostic.ERROR, DIAGNOSTIC_SOURCE, EOBJECT__EVERY_MULTIPCITY_CONFORMS, "_UI_DocumentRootMustHaveOneElement_diagnostic", new Object [] { getFeatureLabel(eStructuralFeature, context), getObjectLabel(eObject, context), count }, new Object [] { eObject, eStructuralFeature }, context)); } } } Is our model wrong? Is there a bug in EObjectValidator? Thanks. Reproducible: Always Steps to Reproduce: Can only be reproduced in our product.