|
| Re: [Xpand] How to get xmi id from an xpand template [message #647670 is a reply to message #647666] |
Fri, 07 January 2011 12:01   |
Christian Dietrich Messages: 4420 Registered: July 2009 |
Senior Member |
|
|
Hi,
Since XMI is just one way of Persisting stuff reading the XMI Id is not a default usecase.
why do you need the xmi ids?
but this java extension should do the stuff.
package template;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.xmi.XMLResource;
public class Extensions {
public static String xmiId(EObject x) {
Resource resouce = x.eResource();
if (resouce instanceof XMLResource) {
XMLResource xmlResource = (XMLResource)resouce;
return xmlResource.getID(x);
}
return "";
}
}
template/GeneratorExtensions.ext
String xmiID(emf::EObject x) :
JAVA template.Extensions.xmiId(org.eclipse.emf.ecore.EObject);
template.xpt
«EXTENSION template::GeneratorExtensions»
....
«DEFINE main FOR test::Bean»
....
//«this.xmiID()»
....
see http://www.openarchitectureware.org/forum/viewtopic.php?foru m=2&showtopic=14730&highlight=xmiid
~Christian
[Updated on: Fri, 07 January 2011 12:02] Report message to a moderator
|
|
|
| Re: [Xpand] How to get xmi id from an xpand template [message #647696 is a reply to message #647670] |
Fri, 07 January 2011 14:15  |
Eclipse User Messages: 14 Registered: January 2011 |
Junior Member |
|
|
Hi Christian,
Some of the downstream tools that will be utilizing the xpand output for this particular usage scenario needed the xmi id. I tried out your recommended approach, and it works as expected.
Thanks again for your quick responses. It is most appreciated!!
Cheers,
Lourdes
|
|
|
Powered by
FUDForum. Page generated in 0.07256 seconds