Problem with ExtendedMetaData [message #1015092] |
Wed, 27 February 2013 07:43  |
Eclipse User |
|
|
|
I've a problem with EMF and ExtendedMetaData.
I tried with a really small ecore model where 'A' contains 'B's through a reference 'attr'. I change the name of this reference to 'attribute' using an ExtendedMetaData anotation.
<ecore:EPackage xmi:version="2.0" xmlns:xmi="htxp://www.omg.org/XMI" xmlns:xsi="htxp://www.w3.org/2001/XMLSchema-instance"
xmlns:ecore="htxp://www.eclipse.org/emf/2002/Ecore" name="a" nsURI="a" nsPrefix="a">
<eAnnotations source="htxp:///org/eclipse/emf/ecore/util/ExtendedMetaData">
<details key="qualified" value="false"/>
</eAnnotations>
<eClassifiers xsi:type="ecore:EClass" name="A">
<eStructuralFeatures xsi:type="ecore:EReference" name="attr" upperBound="-1" eType="#//B"
containment="true">
<eAnnotations source="htxp:///org/eclipse/emf/ecore/util/ExtendedMetaData">
<details key="name" value="attribute"/>
</eAnnotations>
</eStructuralFeatures>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="B">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="x" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
</eClassifiers>
</ecore:EPackage>
From this I generate a genmodel and then generat code (model, edit and editor) and start the runtime workbench.
I create a model using the model wizard for this ecore model and it seems to be ok. The reference chnage from 'attr' to 'attribute'.
<?xml version="1.0" encoding="UTF-8"?>
<A xmlns:xsi="htxp://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="a">
<attribute x="x"/>
</A>
When I close it and and try to open it again with the same editor I created it in I get an error (attached as image also, as is the stack trace):
Problem encountered in file "platform/resource/a/My.a"
FeatureNotFoundExeption: Feature 'attribute' not found (platform/resource/a/My.a,3,21)
If I open the model and change the name of the references backto 'attr' (as defined if the ExtendedMetaData wasn't set) it works, ie. it can be loaded.
Can someone explain this behavior to me?
I use:
- Kepler Release Build id: 20130207-1142
- EMF 2.9.0
PS. Due to this "You can only use links to eclipse.org sites while you have fewer than 5 messages." I have to use htxp instated of http. DS
|
|
|
|
|
Re: Problem with ExtendedMetaData [message #1015125 is a reply to message #1015107] |
Wed, 27 February 2013 09:25   |
Eclipse User |
|
|
|
Patrik,
You're sure this resource factory getting used? You could set a
breakpoint in
org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.getFeature(EClass, String,
String, boolean) to see why it's failing. You can make the breakpoint
conditional on name being the name of the feature in question...
On 27/02/2013 2:30 PM, Patrik Nandorf wrote:
> yes, it seems
>
>
> /**
> * Creates an instance of the resource.
> * <!-- begin-user-doc -->
> * <!-- end-user-doc -->
> * @generated
> */
> @Override
> public Resource createResource(URI uri) {
> XMLResource result = new AResourceImpl(uri);
> result.getDefaultSaveOptions().put(XMLResource.OPTION_EXTENDED_META_DATA,
> extendedMetaData);
> result.getDefaultLoadOptions().put(XMLResource.OPTION_EXTENDED_META_DATA,
> extendedMetaData);
>
> result.getDefaultSaveOptions().put(XMLResource.OPTION_SCHEMA_LOCATION,
> Boolean.TRUE);
>
> result.getDefaultLoadOptions().put(XMLResource.OPTION_USE_ENCODED_ATTRIBUTE_STYLE,
> Boolean.TRUE);
> result.getDefaultSaveOptions().put(XMLResource.OPTION_USE_ENCODED_ATTRIBUTE_STYLE,
> Boolean.TRUE);
>
> result.getDefaultLoadOptions().put(XMLResource.OPTION_USE_LEXICAL_HANDLER,
> Boolean.TRUE);
> return result;
> }
>
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.28175 seconds