HOW to register UML resources? [message #631318] |
Wed, 06 October 2010 23:31  |
Eclipse User |
|
|
|
I am already have a ecore parser with OCL ,so I always want to do little change to parser UML with OCL.
But so far , it seems more difficult than ecore .
In ecore:
ResourceSet resourceSet = new ResourceSetImpl();
resourceSet.getResourceFactoryRegistry().getExtensionToFacto ryMap().put(
"ecore", new EcoreResourceFactoryImpl());
URI myEcoreURI = URI.createFileURI(file.getAbsolutePath()); //file is .ecore file.
Resource myEcoreResource = resourceSet.getResource(myEcoreURI, true);
i can easily get my resource.
But in UML:
resourceSet.getPackageRegistry().put(UMLPackage.eNS_URI, UMLPackage.eINSTANCE);
resourceSet.getResourceFactoryRegistry().getExtensionToFacto ryMap().put( "uml", new UMLResourceFactoryImpl());
URI UMLuri = URI.createFileURI(umlfile.getAbsolutePath()); umlfile is .uml file.
***Resource resource = resourceSet.getResource(UMLuri, true);
I got exception about my resources...OH my goodness!
Exception in thread "main" java.lang.NoSuchMethodError: org.eclipse.emf.ecore.resource.URIConverter.createInputStrea m(Lorg/eclipse/emf/common/util/URI;Ljava/util/Map;)Ljava/io/ InputStream;
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.getPackageForURI(X MLHandler.java:2533)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.getFactoryForPrefi x(XMLHandler.java:2421)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObjectByType (XMLHandler.java:1299)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.createTopObject(XM LHandler.java:1468)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.processElement(XML Handler.java:1019)
at org.eclipse.emf.ecore.xmi.impl.XMIHandler.processElement(XMI Handler.javple
Please help me!!!
how to get my UML resources?
best regards
hutzu
|
|
|
|
Re: HOW to register UML resources? [message #631966 is a reply to message #631321] |
Mon, 11 October 2010 01:00  |
Eclipse User |
|
|
|
Thanks a lot,Rafael
it really work~
My objective is to parse class diagram with OCL.
In ecore , first i need to parse ecore diagram to get "ArrayList<EPackageImpl> ".
shall i do the same thing in UML2 class diagram?
To write a parser to get ArrayList<EPackageImpl> , and then register the UML2
am i right?
best regards
hutzu
|
|
|
Powered by
FUDForum. Page generated in 0.04506 seconds