Skip to main content



      Home
Home » Modeling » EMF » "Feature not found" error in XMI file parsing using EMF
"Feature not found" error in XMI file parsing using EMF [message #415463] Fri, 14 December 2007 09:01 Go to next message
Eclipse UserFriend
Originally posted by: s.balard.prometil.com

Hi,
I want to use a xmi file content throught a java structure. To do this, i
use EMF.
I have generated XMI and UML java classes from UML2XMI.xsd using EMF
internal ecore model.
I have created a short program to test this java structure whose main
method is :

public static void main(String[] args) {

ResourceSet resourceSet = new ResourceSetImpl();

final ExtendedMetaData extendedMetaData = new BasicExtendedMetaData(
resourceSet.getPackageRegistry());
resourceSet.getLoadOptions().put(XMLResource.OPTION_EXTENDED _META_DATA,
extendedMetaData);
resourceSet.getPackageRegistry().put("xmi", XmiPackage.eINSTANCE);
resourceSet.getPackageRegistry().put("uml", UmlPackage.eINSTANCE);
resourceSet.getResourceFactoryRegistry().getExtensionToFacto ryMap()
.put("xmi", new XmiResourceFactoryImpl());
resourceSet.getResourceFactoryRegistry().getExtensionToFacto ryMap()
.put("uml", new UmlResourceFactoryImpl());


URI fileURI = URI.createFileURI(new File(
"resources/diagram.xmi").getAbsolutePath());

Resource resource = resourceSet.getResource(fileURI, true);
System.out.println("ok");
}

Here, first lines of XMI file :

<?xml version="1.0" encoding="UTF-8"?>
<xmi:XMI xmi:version="2.0"
xmlns:xmi="http://www.omg.org/XMI"
xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore"
xmlns:notation="http://www.eclipse.org/gmf/runtime/1.0.1/notation"
xmlns:org.eclipse.epf.diagram.model="http://www.eclipse.org/epf/diagram/1.0.0/diagram.ecore"

xmlns:org.eclipse.epf.uma="http://www.eclipse.org/epf/uma/1.0.4/uma.ecore"
xmlns:uml="http://www.eclipse.org/uml2/2.1.0/UML">
<uml:Activity xmi:id="_QIQIMI4eEdycJJIpQMvv6A" name="Revue formelle">
<eAnnotations xmi:type="ecore:EAnnotation"
xmi:id="_QIQIMY4eEdycJJIpQMvv6A" source="uma_element">
<details xmi:type="ecore:EStringToStringMapEntry"
xmi:id="_QIQIMo4eEdycJJIpQMvv6A"
key="uri"
value="uma://_K_OTUI3mEdysnYhuhetZFw#_K_OTUY3mEdysnYhuhetZFw"/>
<details xmi:type="ecore:EStringToStringMapEntry"
xmi:id="_QIQIM44eEdycJJIpQMvv6A"
key="type" value="Activity"/>
</eAnnotations>
<node xmi:type="uml:StructuredActivityNode"
xmi:id="_QJWUYI4eEdycJJIpQMvv6A" name="Phase d'initialisation"
outgoing="_Y05IMI4eEdycJJIpQMvv6A"
incoming="_YB7aMI4eEdycJJIpQMvv6A">
<eAnnotations xmi:type="ecore:EAnnotation"
xmi:id="_QJWUYY4eEdycJJIpQMvv6A"
source="uma_element">
<details xmi:type="ecore:EStringToStringMapEntry"
xmi:id="_QJWUYo4eEdycJJIpQMvv6A"
key="uri"
value="uma://_K_OTUI3mEdysnYhuhetZFw#_nPjf8Y3nEdysnYhuhetZFw"/>
<details xmi:type="ecore:EStringToStringMapEntry"
xmi:id="_QJWUY44eEdycJJIpQMvv6A"
key="type" value="Phase"/>
</eAnnotations>
</node>
...
</xmi:XMI>

During main method execution, an exception is thrown :

Exception in thread "main"
org.eclipse.emf.ecore.resource.impl.ResourceSetImpl$1Diagnos ticWrappedException:
org.eclipse.emf.ecore.xmi.FeatureNotFoundException: Feature 'Activity' not
found. (file:/F:/workspace/wtp/XMI2ECORE/resources/diagram.xmi, 6, 72)
at
org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.handleDe mandLoadException(ResourceSetImpl.java:316)
at
org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLo adHelper(ResourceSetImpl.java:275)
at
org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResou rce(ResourceSetImpl.java:398)
at
com.prometil.epf.xmi.parser.TestEFPXMIParser.main(TestEFPXMI Parser.java:101)

I defined a Resource Factories, one for xmi markups another for uml
markups however parser does not recognize <uml:Activity> markup.
Can anyone explain to me where i make a mistake ?

Regards,
Sebastien BALARD
Re: "Feature not found" error in XMI file parsing using EMF [message #415467 is a reply to message #415463] Fri, 14 December 2007 13:42 Go to previous message
Eclipse UserFriend
Sebastien,

Comments below.

Sebastien BALARD wrote:
> Hi,
> I want to use a xmi file content throught a java structure. To do
> this, i use EMF.
> I have generated XMI and UML java classes from UML2XMI.xsd using EMF
> internal ecore model.
Gross. That sound horrible. XMI schemas are terrible things that don't
properly describe structure. The UML model is already generated so
you'd use that for processing UML instances.
> I have created a short program to test this java structure whose main
> method is :
>
> public static void main(String[] args) {
>
> ResourceSet resourceSet = new ResourceSetImpl();
>
> final ExtendedMetaData extendedMetaData = new BasicExtendedMetaData(
> resourceSet.getPackageRegistry());
> resourceSet.getLoadOptions().put(XMLResource.OPTION_EXTENDED _META_DATA,
>
> extendedMetaData);
> resourceSet.getPackageRegistry().put("xmi", XmiPackage.eINSTANCE);
> resourceSet.getPackageRegistry().put("uml", UmlPackage.eINSTANCE);
> resourceSet.getResourceFactoryRegistry().getExtensionToFacto ryMap()
> .put("xmi", new XmiResourceFactoryImpl());
> resourceSet.getResourceFactoryRegistry().getExtensionToFacto ryMap()
> .put("uml", new UmlResourceFactoryImpl());
>
>
> URI fileURI = URI.createFileURI(new File(
> "resources/diagram.xmi").getAbsolutePath());
>
> Resource resource = resourceSet.getResource(fileURI, true);
> System.out.println("ok");
> }
>
> Here, first lines of XMI file :
>
> <?xml version="1.0" encoding="UTF-8"?>
> <xmi:XMI xmi:version="2.0"
> xmlns:xmi="http://www.omg.org/XMI"
> xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore"
> xmlns:notation="http://www.eclipse.org/gmf/runtime/1.0.1/notation"
> xmlns:org.eclipse.epf.diagram.model="http://www.eclipse.org/epf/diagram/1.0.0/diagram.ecore"
>
>
> xmlns:org.eclipse.epf.uma="http://www.eclipse.org/epf/uma/1.0.4/uma.ecore"
> xmlns:uml="http://www.eclipse.org/uml2/2.1.0/UML">
> <uml:Activity xmi:id="_QIQIMI4eEdycJJIpQMvv6A" name="Revue formelle">
> <eAnnotations xmi:type="ecore:EAnnotation"
> xmi:id="_QIQIMY4eEdycJJIpQMvv6A" source="uma_element">
> <details xmi:type="ecore:EStringToStringMapEntry"
> xmi:id="_QIQIMo4eEdycJJIpQMvv6A"
> key="uri"
> value="uma://_K_OTUI3mEdysnYhuhetZFw#_K_OTUY3mEdysnYhuhetZFw"/>
> <details xmi:type="ecore:EStringToStringMapEntry"
> xmi:id="_QIQIM44eEdycJJIpQMvv6A"
> key="type" value="Activity"/>
> </eAnnotations>
> <node xmi:type="uml:StructuredActivityNode"
> xmi:id="_QJWUYI4eEdycJJIpQMvv6A" name="Phase d'initialisation"
> outgoing="_Y05IMI4eEdycJJIpQMvv6A"
> incoming="_YB7aMI4eEdycJJIpQMvv6A">
> <eAnnotations xmi:type="ecore:EAnnotation"
> xmi:id="_QJWUYY4eEdycJJIpQMvv6A"
> source="uma_element">
> <details xmi:type="ecore:EStringToStringMapEntry"
> xmi:id="_QJWUYo4eEdycJJIpQMvv6A"
> key="uri"
> value="uma://_K_OTUI3mEdysnYhuhetZFw#_nPjf8Y3nEdysnYhuhetZFw"/>
> <details xmi:type="ecore:EStringToStringMapEntry"
> xmi:id="_QJWUY44eEdycJJIpQMvv6A"
> key="type" value="Phase"/>
> </eAnnotations>
> </node>
> ...
> </xmi:XMI>
>
> During main method execution, an exception is thrown :
>
> Exception in thread "main"
> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl$1Diagnos ticWrappedException:
> org.eclipse.emf.ecore.xmi.FeatureNotFoundException: Feature 'Activity'
> not found. (file:/F:/workspace/wtp/XMI2ECORE/resources/diagram.xmi, 6,
> 72)
> at
> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.handleDe mandLoadException(ResourceSetImpl.java:316)
>
> at
> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLo adHelper(ResourceSetImpl.java:275)
>
> at
> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResou rce(ResourceSetImpl.java:398)
>
> at
> com.prometil.epf.xmi.parser.TestEFPXMIParser.main(TestEFPXMI Parser.java:101)
>
>
> I defined a Resource Factories, one for xmi markups another for uml
> markups however parser does not recognize <uml:Activity> markup.
> Can anyone explain to me where i make a mistake ?
This sounds like completely the wrong approach. The UML model and GMF
provide model implementations already, along with resource factories set
up to process these types of XMI files, so you should be using those
directly, not trying to reconstruct some type of analog from the XMI
Schema representation for them.
>
> Regards,
> Sebastien BALARD
>
Previous Topic:Is the use of eResource().setURI() OK?
Next Topic:How to read out emf-supertypes??
Goto Forum:
  


Current Time: Mon Jul 28 14:45:19 EDT 2025

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

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

Back to the top