Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » passing parameters
passing parameters [message #14457] Mon, 30 April 2007 20:30 Go to next message
Eclipse User
Originally posted by: ymo.noemail.com

Hi.

Is it possible to pass parameters to a main.jet startup file ? For example
i would like my templates to generate multiple target files based on the
parameters that were passed to the main.jet file.
Re: passing parameters [message #14518 is a reply to message #14457] Tue, 01 May 2007 13:02 Go to previous message
Paul Elder is currently offline Paul Elder
Messages: 849
Registered: July 2009
Senior Member
You have two choices for passing parameters to a JET transform.

1) Put the information in the 'model' that is being loaded by the
transformation. In a previous post, it looked like you are loading a
document that conforms to a predefined schema, so this may not be an option.
Another alternative is to create a 'driver' model that the transform loads
as input, and have it reference the main document you want to process. You
driver document might look something like this:

<page path="input relative path to page to load" otherParm1="..."
otherParm2="..."/>

In main.jet, you could then use the c:load tag to load the 'real' document:

<c:setVariable var="pageDriver" select="/page"/>
<!-- $org.eclipse.jet.resource.parent.fullPath is the workspace path of the
input's container,
Use it to resolve and load $pageDriver/@path -->
<c:load var="pageDocument"
url={$org.eclipse.jet.resource.parent.fullPath}/{$pageDirver /@path}
type="xml"/>
<!-- pageDocument is the "DocumentRoot" (equivalent of /) in the loaded
document. So, if you normally write:
/root/view/ui, you'd write $pageDocument/root/view/ui -->

You can get more information on predefined variables like
org.eclipse.jet.resource.parentFullPath at:

http://help.eclipse.org/help32/index.jsp?topic=/org.eclipse. jet.doc/references/xpath/predefinedVariables.xhtml

And, more information on c:load at:

http://help.eclipse.org/help32/index.jsp?topic=/org.eclipse. jet.doc/references/taglibs/controlTags/loadTag.html


2) When using the JET2Platform.runTransformOnXXX() APIs, you can pass a Map
defining XPath variables. Each key is a variable name; each value is the
value. You can pass Strings, Booleans, subclasses of Number. Note that the
UI does not support this capability, so it will only work if you are
invoking the transform from this API.

Paul


"ymo" <ymo@noemail.com> wrote in message
news:08c41e94ed87571a442cd634c94e9df3$1@www.eclipse.org...
> Hi.
>
> Is it possible to pass parameters to a main.jet startup file ? For example
> i would like my templates to generate multiple target files based on the
> parameters that were passed to the main.jet file.
>
Previous Topic:xml namespace parsing
Next Topic:changing "jet settings" properties creates problem
Goto Forum:
  


Current Time: Wed Oct 01 04:00:53 GMT 2014

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

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