Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » AJDT » Loading UML file from MagicDraw 11
Loading UML file from MagicDraw 11 [message #66034] Mon, 03 July 2006 11:30 Go to next message
Eclipse User
Originally posted by: benjamin.mesing.informatik.uni-rostock.de

Hello,

I've tried to get loading of MagicDraw xmi files working for some time
now, however I haven't succeeded yet.

I am not really sure what I do wrong, but I do not really understand the
UML2 and EMF libraries yet. I understand that the following line
registers the UMLFactory for the .uml extension.

Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap( ).put(UMLResource.FILE_EXTENSION,
UMLResource.Factory.INSTANCE);
Do I have to register this factory for .xmi too? Or should I register
the XMIResourceFactoryImpl?

I have the following test file which I would like to load:

<?xml version='1.0' encoding='UTF-8'?>
<xmi:XMI xmi:version='2.1' timestamp='Mon Jun 26 11:17:36 CEST 2006'
xmlns:uml='http://schema.omg.org/spec/UML/2.0'
xmlns:xmi='http://schema.omg.org/spec/XMI/2.1'>
<uml:Model xmi:id='eee_1045467100313_135436_1' name='Data' visibility='public'>
<ownedMember xmi:type='uml:Class' xmi:id='_11_0_1_2610136_1151307651168_829099_5' name='Class1MagicDraw&#10;' visibility='public'>
<ownedOperation xmi:type='uml:Operation' xmi:id='_11_0_1_2610136_1151307711917_114728_52' concurrency='sequential' name='helloWorld' visibility='public'/>
</ownedMember>
<ownedMember xmi:type='uml:Class' xmi:id='_11_0_1_2610136_1151307668268_345223_23' name='Class2Magic&#10;Draw' visibility='public'>
<generalization xmi:type='uml:Generalization' xmi:id='_11_0_1_2610136_1151307689897_650305_41' general='_11_0_1_2610136_1151307651168_829099_5'/>
</ownedMember>
</uml:Model>
</xmi:XMI>

The loading routine I am using looks roughly like this:

public void load(URI uri) throws TypeException
{
Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap( ).put(UMLResource.FILE_EXTENSION,
UMLResource.Factory.INSTANCE);
Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap( ).put( "xmi",
new XMIResourceFactoryImpl());
UMLPackage pkg = UMLPackage.eINSTANCE;

org.eclipse.uml2.uml.Package package_ = null;
try
{
Resource resource = RESOURCE_SET.getResource(uri, true);
package_ = (org.eclipse.uml2.uml.Package) EcoreUtil.getObjectByType(resource.getContents(),
UMLPackage.eINSTANCE.getPackage());
}
catch (WrappedException we)
{
System.err.println(we.getMessage());
System.exit(1);
}
if (package_ == null)
{
System.out.println("Parsing XMI file failed");
System.exit(1);
}
}

When using things like shown above, loading fails with the following
message:
org.eclipse.emf.ecore.xmi.PackageNotFoundException: Package with
uri 'http://schema.omg.org/spec/UML/2.0' not found.
(file:/<path>/test-magicDraw-manual-edit-small.xmi, 3, 81)

If I trim it down, and make it look more like a UML2 file by removing
the <xmi> tag and using the uml2 namespace I get a different error.
<?xml version='1.0' encoding='UTF-8'?>
<uml:Model xmi:id='eee_1045467100313_135436_1' name='Data' visibility='public'
xmlns:xmi="http://schema.omg.org/spec/XMI/2.1"
xmlns:uml="http://www.eclipse.org/uml2/2.0.0/UML" xmi:version='2.1'>
[...]
</uml:Model>

Registering the UML2 NS_URI:
RESOURCE_SET.getPackageRegistry().put("http://schema.omg.org/spec/UML/2.0", UMLPackage.eINSTANCE);
leads to the following error:
org.eclipse.emf.ecore.xmi.IllegalValueException: Value
'org.eclipse.uml2.uml.internal.impl.ClassImpl@2e7820 (name:
Class1MagicDraw
, visibility: <unset>) (isLeaf: false, visibility: public,
isAbstract: false) (isActive: false, isAbstract: false)' is not
legal. (file:/<paths>/test-magicDraw-manual-edit-small.xmi, 6,
133)

This seems to be due to the <ownedMember> elements since changing them to
<ownedType> finally makes the file load fine:
<?xml version='1.0' encoding='UTF-8'?>
<uml:Model xmi:id='eee_1045467100313_135436_1' name='Data' visibility='public' xmlns:xmi="http://schema.omg.org/spec/XMI/2.1" xmlns:uml="http://www.eclipse.org/uml2/2.0.0/UML" xmi:version='2.1'>
<ownedType xmi:type='uml:Class' xmi:id='_11_0_1_2610136_1151307651168_829099_5' name='Class1MagicDraw&#10;' visibility='public'>
<ownedOperation xmi:type='uml:Operation' xmi:id='_11_0_1_2610136_1151307711917_114728_52' concurrency='sequential' name='helloWorld' visibility='public'/>
</ownedType>
<ownedType xmi:type='uml:Class' xmi:id='_11_0_1_2610136_1151307668268_345223_23' name='Class2Magic&#10;Draw' visibility='public'>
<generalization xmi:type='uml:Generalization' xmi:id='_11_0_1_2610136_1151307689897_650305_41' general='_11_0_1_2610136_1151307651168_829099_5'/>
</ownedType>
</uml:Model>

How are things supposed to work? I am totally at a loss, so any help
would be appreciated. I could perform an XSLT, but I would rather
first understand how things work.

I am using EMF 2.2 and UML2 2.0.0

Best regards

Ben
Re: Loading UML file from MagicDraw 11 [message #66055 is a reply to message #66034] Mon, 03 July 2006 11:31 Go to previous message
Eclipse User
Originally posted by: benjamin.mesing.informatik.uni-rostock.de

Sorry, that was intented for eclipse.tools.uml2
Re: Loading UML file from MagicDraw 11 [message #594280 is a reply to message #66034] Mon, 03 July 2006 11:31 Go to previous message
Eclipse User
Originally posted by: benjamin.mesing.informatik.uni-rostock.de

Sorry, that was intented for eclipse.tools.uml2
Previous Topic:Loading UML file from MagicDraw 11
Next Topic:Product Export problem
Goto Forum:
  


Current Time: Thu Aug 28 09:25:02 EDT 2014

Powered by FUDForum. Page generated in 0.02161 seconds