Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » UML2 » Trouble Creating Ports and Interfaces
Trouble Creating Ports and Interfaces [message #628440] Mon, 10 May 2010 21:31
William Koscho is currently offline William KoschoFriend
Messages: 10
Registered: May 2010
Junior Member
Im hoping someone can help me, as I'm trying to create a port with provided and required interfaces and save as XMI. I essentially have three problems:

1. The problem is that the code serializes ports in XMI as <ownedAttribute> but I would like this to be <ownedPort> , how can I do this?

2. I cannot get it to work with required interfaces, as it reports UnsupportedException. I found a posting indicating that I must specify some additional classifier information, but I was not sure exactly how to do that, any additional information is appreciated.

3. The XMI produced uses the xsi: prefix instead of the xmi: prefix, how can I change that?

My code snippet is as follows:

// create the port
Port p = UMLFactory.eINSTANCE.createPort();
Interface i = UMLFactory.eINSTANCE.createInterface();
// TODO - add provides interfaces

// create the component
Component component = UMLFactory.eINSTANCE.createComponent();

// populate the model

// save it as XMI
ResourceSet resourceSet = new ResourceSetImpl();
UMLFactory factory = UMLFactory.eINSTANCE;

resourceSet.getResourceFactoryRegistry().getExtensionToFacto ryMap().put(Resource.Factory.Registry.DEFAULT_EXTENSION, new XMIResourceFactoryImpl());

resourceSet.getPackageRegistry().put(UMLPackage.eNS_URI, UMLPackage.eINSTANCE);

URI fileURI = URI.createFileURI(new File("c:\\temp\\exported_model.xmi").getAbsolutePath());

Resource resource = resourceSet.createResource(fileURI);
resource.getContents().add(model);, Collections.EMPTY_MAP);

The output XMI file is:

<?xml version="1.0" encoding="ASCII"?>
<uml:Model xmi:version="2.0" xmlns:xmi="" xmlns:xsi="" xmlns:uml="">
<packagedElement xsi:type="uml:Package" name="Test4">
<packagedElement xsi:type="uml:Component" name="c1">
<ownedAttribute xsi:type="uml:Port" name="p" visibility="public" aggregation="composite"/>
<packagedElement xsi:type="uml:Component" name="c2">
<ownedAttribute xsi:type="uml:Port" name="p" visibility="public" aggregation="composite"/>

Previous Topic:Trouble Creating Ports and Interfaces
Next Topic:how to use metamodels to create models??
Goto Forum:

Current Time: Thu May 24 12:19:29 GMT 2018

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

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

Back to the top