Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » UML2 » problems in reading an uml/xmi file
problems in reading an uml/xmi file [message #478290] Wed, 08 April 2009 11:11 Go to next message
Nick Betteridge is currently offline Nick BetteridgeFriend
Messages: 6
Registered: July 2009
Junior Member
Been using the sdk for reading/writing my own uml models for quite a while
and love it! Spent the whole of yesterday trying to read an xmi file and
I've really hit a wall.

I'm doing this in standalone mode.

The uml xmi file is:

http://www.omg.org/spec/FUML/20080802/08-08-06.xmi

The first line defines the versions:

<uml:Model xmi:version="2.1" xmlns:xmi="http://schema.omg.org/spec/XMI/2.1"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore"
xmlns:uml="http://schema.omg.org/spec/UML/2.1.1"
xsi:schemaLocation="http://schema.omg.org/spec/UML/2.1.1
http://www.eclipse.org/uml2/2.1.0/UML"
xmi:id="_UlCZgHLxEd23psn_hP0YDw" name="fUML_Semantics">


... so I downloaded the eclipse uml 2.1.0 sdk and the emf
emf-sdo-runtime-2.3.0,jar and add all of the jars to the classpath.

rename 08-08-06.xmi to 08-08-06.uml

The java is :

ResourceSet RESOURCE_SET = new ResourceSetImpl();
RESOURCE_SET.getPackageRegistry().put(UMLPackage.eNS_URI,
UMLPackage.eINSTANCE);
RESOURCE_SET.getResourceFactoryRegistry().getExtensionToFact oryMap().put(UMLResource.FILE_EXTENSION,
UMLResource.Factory.INSTANCE);
Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap( ).put(
UMLResource.FILE_EXTENSION, UMLResource.Factory.INSTANCE);
URI uri = getPathMapURI("profiles/UML2.profile.uml");
URIConverter.URI_MAP.put(URI.createURI(UMLResource.LIBRARIES _PATHMAP),
uri.appendSegment("libraries").appendSegment(""));
URIConverter.URI_MAP.put(URI.createURI(UMLResource.METAMODEL S_PATHMAP),
uri.appendSegment("metamodels").appendSegment(""));
URIConverter.URI_MAP.put(URI.createURI(UMLResource.PROFILES_ PATHMAP),
uri.appendSegment("profiles").appendSegment(""));

Resource resource =
RESOURCE_SET.getResource(modelLibFileURI.
appendSegment("08-08-06").
appendFileExtension(UMLResource.FILE_EXTENSION), true);

Model model = (Model)EcoreUtil.getObjectByType(resource.getContents(),
UMLPackage.Literals.PACKAGE);


when I do a list on model.allOwnedElements(), all I get is:

PackageImportImpl@12d96f2 (visibility: public)
PackageImpl@af993e (name: Semantics, visibility: <unset>) (visibility:
public)


.... all of the classes etc have just disappeared.

Does anyone know of a way forward?

Thanks

Nick
Re: problems in reading an uml/xmi file [message #478292 is a reply to message #478290] Wed, 08 April 2009 19:42 Go to previous message
Lazar Codrut-Lucian is currently offline Lazar Codrut-LucianFriend
Messages: 91
Registered: July 2009
Member
That file is not compatible with Eclipse UML2.
If you try to open it with the UML Editor and expand a few nodes, you'll
get an error in no time (probably as soon as you expand the last package
you see in your output).
My suggestion is to open it with a text editor (or with an XML viewer)
to see its structure and how the code and documentation of the classes
is stored inside.
And use plain DOM to generate the code from it (if that's what you're
trying to achieve).

Lucian


Nick Betteridge wrote:
> Been using the sdk for reading/writing my own uml models for quite a
> while and love it! Spent the whole of yesterday trying to read an xmi
> file and I've really hit a wall.
>
> I'm doing this in standalone mode.
>
> The uml xmi file is:
>
> http://www.omg.org/spec/FUML/20080802/08-08-06.xmi
>
> The first line defines the versions:
>
> <uml:Model xmi:version="2.1" xmlns:xmi="http://schema.omg.org/spec/XMI/2.1"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore"
> xmlns:uml="http://schema.omg.org/spec/UML/2.1.1"
> xsi:schemaLocation="http://schema.omg.org/spec/UML/2.1.1
> http://www.eclipse.org/uml2/2.1.0/UML"
> xmi:id="_UlCZgHLxEd23psn_hP0YDw" name="fUML_Semantics">
>
>
> .. so I downloaded the eclipse uml 2.1.0 sdk and the emf
> emf-sdo-runtime-2.3.0,jar and add all of the jars to the classpath.
>
> rename 08-08-06.xmi to 08-08-06.uml
>
> The java is :
>
> ResourceSet RESOURCE_SET = new ResourceSetImpl();
> RESOURCE_SET.getPackageRegistry().put(UMLPackage.eNS_URI,
> UMLPackage.eINSTANCE);
> RESOURCE_SET.getResourceFactoryRegistry().getExtensionToFact oryMap().put(UMLResource.FILE_EXTENSION,
> UMLResource.Factory.INSTANCE);
> Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap( ).put(
> UMLResource.FILE_EXTENSION, UMLResource.Factory.INSTANCE);
> URI uri = getPathMapURI("profiles/UML2.profile.uml");
> URIConverter.URI_MAP.put(URI.createURI(UMLResource.LIBRARIES _PATHMAP),
> uri.appendSegment("libraries").appendSegment(""));
> URIConverter.URI_MAP.put(URI.createURI(UMLResource.METAMODEL S_PATHMAP),
> uri.appendSegment("metamodels").appendSegment(""));
> URIConverter.URI_MAP.put(URI.createURI(UMLResource.PROFILES_ PATHMAP),
> uri.appendSegment("profiles").appendSegment(""));
>
> Resource resource =
> RESOURCE_SET.getResource(modelLibFileURI.
> appendSegment("08-08-06").
> appendFileExtension(UMLResource.FILE_EXTENSION), true);
>
> Model model = (Model)EcoreUtil.getObjectByType(resource.getContents(),
> UMLPackage.Literals.PACKAGE);
>
>
> when I do a list on model.allOwnedElements(), all I get is:
>
> PackageImportImpl@12d96f2 (visibility: public)
> PackageImpl@af993e (name: Semantics, visibility: <unset>) (visibility:
> public)
>
>
> ... all of the classes etc have just disappeared.
>
> Does anyone know of a way forward?
>
> Thanks
>
> Nick
>
>
Re: problems in reading an uml/xmi file [message #627482 is a reply to message #478290] Wed, 08 April 2009 19:42 Go to previous message
Lazar Codrut-Lucian is currently offline Lazar Codrut-LucianFriend
Messages: 91
Registered: July 2009
Member
That file is not compatible with Eclipse UML2.
If you try to open it with the UML Editor and expand a few nodes, you'll
get an error in no time (probably as soon as you expand the last package
you see in your output).
My suggestion is to open it with a text editor (or with an XML viewer)
to see its structure and how the code and documentation of the classes
is stored inside.
And use plain DOM to generate the code from it (if that's what you're
trying to achieve).

Lucian


Nick Betteridge wrote:
> Been using the sdk for reading/writing my own uml models for quite a
> while and love it! Spent the whole of yesterday trying to read an xmi
> file and I've really hit a wall.
>
> I'm doing this in standalone mode.
>
> The uml xmi file is:
>
> http://www.omg.org/spec/FUML/20080802/08-08-06.xmi
>
> The first line defines the versions:
>
> <uml:Model xmi:version="2.1" xmlns:xmi="http://schema.omg.org/spec/XMI/2.1"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore"
> xmlns:uml="http://schema.omg.org/spec/UML/2.1.1"
> xsi:schemaLocation="http://schema.omg.org/spec/UML/2.1.1
> http://www.eclipse.org/uml2/2.1.0/UML"
> xmi:id="_UlCZgHLxEd23psn_hP0YDw" name="fUML_Semantics">
>
>
> .. so I downloaded the eclipse uml 2.1.0 sdk and the emf
> emf-sdo-runtime-2.3.0,jar and add all of the jars to the classpath.
>
> rename 08-08-06.xmi to 08-08-06.uml
>
> The java is :
>
> ResourceSet RESOURCE_SET = new ResourceSetImpl();
> RESOURCE_SET.getPackageRegistry().put(UMLPackage.eNS_URI,
> UMLPackage.eINSTANCE);
> RESOURCE_SET.getResourceFactoryRegistry().getExtensionToFact oryMap().put(UMLResource.FILE_EXTENSION,
> UMLResource.Factory.INSTANCE);
> Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap( ).put(
> UMLResource.FILE_EXTENSION, UMLResource.Factory.INSTANCE);
> URI uri = getPathMapURI("profiles/UML2.profile.uml");
> URIConverter.URI_MAP.put(URI.createURI(UMLResource.LIBRARIES _PATHMAP),
> uri.appendSegment("libraries").appendSegment(""));
> URIConverter.URI_MAP.put(URI.createURI(UMLResource.METAMODEL S_PATHMAP),
> uri.appendSegment("metamodels").appendSegment(""));
> URIConverter.URI_MAP.put(URI.createURI(UMLResource.PROFILES_ PATHMAP),
> uri.appendSegment("profiles").appendSegment(""));
>
> Resource resource =
> RESOURCE_SET.getResource(modelLibFileURI.
> appendSegment("08-08-06").
> appendFileExtension(UMLResource.FILE_EXTENSION), true);
>
> Model model = (Model)EcoreUtil.getObjectByType(resource.getContents(),
> UMLPackage.Literals.PACKAGE);
>
>
> when I do a list on model.allOwnedElements(), all I get is:
>
> PackageImportImpl@12d96f2 (visibility: public)
> PackageImpl@af993e (name: Semantics, visibility: <unset>) (visibility:
> public)
>
>
> ... all of the classes etc have just disappeared.
>
> Does anyone know of a way forward?
>
> Thanks
>
> Nick
>
>
Previous Topic:problems with pathmap
Next Topic:Binding to UML Classes and Ecore Primitive Types
Goto Forum:
  


Current Time: Fri Apr 26 01:09:46 GMT 2024

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

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

Back to the top