Passing arbitrary data to Xpand [message #630696] |
Mon, 04 October 2010 11:29  |
Eclipse User |
|
|
|
Hi,
I'm a newcomer to Xpand and have run into something that I suspect there is a very simple answer to (but haven't found it yet).
I'm starting with an EMF model and wish to generate Java code from it. However, there is various data that I need to make visible to my Xpand template that cannot be found in the model itself. Taking an example, let's assume the model contains an EClass with name='Hello' and I want to generate a corresponding Java class called 'HelloDAO'. No problem - I can say:
«DEFINE DAOClass FOR ecore::EClass»
«FILE name + "DAO.java"»
// DAO code goes here
«ENDFILE»
«ENDDEFINE»
..and that works fine.
However, what my EMF model doesn't tell you is that 'HelloDAO' needs to exist in a package called 'com.example', so I need a 'package com.example' declaration at the top and HelloDAO.java needs to reside in /com/example, relative to my src root. How can I make this information visible to my script?
I'm aware that I can write a Java helper class and expose its methods to my XPT via an .ext file, but given that those Java methods are static, I can't see how I'd pass a separate set of meta-data for each transformation.
Many thanks in advance for any help.
Ben.
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04229 seconds