Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » [Xpand] How to get xmi id from an xpand template
[Xpand] How to get xmi id from an xpand template [message #647666] Fri, 07 January 2011 16:47 Go to next message
Eclipse User is currently offline Eclipse UserFriend
Messages: 14
Registered: January 2011
Junior Member
Hi,

Is there a straightforward way to print out the xmi id of an object from an Xpand template?

In particular, I'm trying to get at the xmi id of an item with a custom uml profile stereotype.

Any advice would be greatly appreciated.

~Lourdes

[Updated on: Fri, 07 January 2011 16:51]

Report message to a moderator

Re: [Xpand] How to get xmi id from an xpand template [message #647670 is a reply to message #647666] Fri, 07 January 2011 17:01 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
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


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de

[Updated on: Fri, 07 January 2011 17: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 19:15 Go to previous message
Eclipse User is currently offline Eclipse UserFriend
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
Previous Topic:[Xpand] Issues retrieving enumeration literal from UML stereotype property
Next Topic:[XPand, MWE2] Why full xtext dependency?
Goto Forum:
  


Current Time: Sat Apr 20 03:07:54 GMT 2024

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

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

Back to the top