Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Convert Path in XMI
Convert Path in XMI [message #1785330] Thu, 12 April 2018 15:05 Go to next message
Alfa Yohannis is currently offline Alfa YohannisFriend
Messages: 3
Registered: April 2018
Junior Member
Dear All,

I have an XMI model as follow:

<?xml version="1.0" encoding="ASCII"?>
<xmi:XMI xmi:version="2.0" xmlns:xmi="apathshouldbehere" xmlns:xsi="apathshouldbehere" xmlns:uml="apathshouldbehere">
	<uml:Model name="org.eclipse.mdt.bpmn2.editor">
		<packagedElement xsi:type="uml:Model" name="Model">
			<packagedElement xsi:type="uml:Package" name="org" visibility="public">
				<packagedElement xsi:type="uml:Class" name="Wizard" visibility="public">
				</packagedElement>
				<packagedElement xsi:type="uml:Class" name="Bpmn2ModelWizard" visibility="public">
					<generalization general="/0/Model/org/@packagedElement.0"/>
				</packagedElement>
			</packagedElement>
		</packagedElement>
	</uml:Model>
</xmi:XMI>


I want to convert the line:

<generalization general="/0/Model/org/@packagedElement.0"/>


to:

<generalization general="/0/@packagedElement.0/@packagedElement.0/@packagedElement.0"/>


How can I do this?

If I use the first format, I cannot load the model using XMIResourceImpl (I use my own customised UML metamodel). If I use the second format, the load works perfectly.

Thank you very much for your help.

Alfa
Re: Convert Path in XMI [message #1785634 is a reply to message #1785330] Tue, 17 April 2018 15:51 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 6033
Registered: July 2009
Senior Member
Hi

(Your message has only just appeared in the RSS feed).

It is not clear where your model comes from since it deviates from the normal Eclipse UML2 formatting.

If you want to do your own thing rather than use the Eclipse UML2 project, then you presumably have significant Ecore skills, so you should be able to fix the load failures of select the appropriate save options or use a custom XMIResourceImpl to avoid using IDs ...

Regards

Ed Willink
Re: Convert Path in XMI [message #1785657 is a reply to message #1785634] Wed, 18 April 2018 05:59 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 29536
Registered: July 2009
Senior Member
Note that the first serialization looks like it's was produced by org.eclipse.emf.ecore.impl.EModelElementImpl.eURIFragmentSegment(EStructuralFeature, EObject) and is interpreted by org.eclipse.emf.ecore.impl.EModelElementImpl.eObjectForURIFragmentSegment(String). You could have a look at org.eclipse.emf.ecore.util.EcoreUtil.getRelativeURIFragmentPath(EObject, EObject, boolean) and at org.eclipse.emf.ecore.resource.impl.ResourceImpl.getURIFragment(EObject) to see how fragment paths are generally computed by the objects themselves and at org.eclipse.emf.ecore.resource.impl.ResourceImpl.getEObject(List<String>) to see how they are interpreted by the objects themselves. This is all to say that there is no general mechanism to convert from oneform of path to the other but rather the implementation classes can be (are) specialized to determine which form is produced and of course must have a corresponding specialization to ensure that such a fragment path segment can also be interpreted. So perhaps the better approach is to ensure that your specialized UML model can interpret the fragment paths the same way as the unspecialized UML2. Generally specializations should be able to interpret the default syntax, e.g., org.eclipse.emf.ecore.impl.EModelElementImpl.eObjectForURIFragmentSegment(String) calls super when the first character in the path segment is an @.
Previous Topic:Some code cannot be generated when Dynamic Templates is true
Next Topic:Custom field on Property object in metamodel
Goto Forum:
  


Current Time: Wed Sep 19 02:05:46 GMT 2018

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

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

Back to the top