Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » Access JET Conext variables in jet
Access JET Conext variables in jet [message #51294] Wed, 20 September 2006 16:59 Go to next message
Kamesh Sampath is currently offline Kamesh SampathFriend
Messages: 191
Registered: July 2009
Senior Member
Hi ,

how to access the passVariables that I have passed from the JETContext
inside the *.jet files.

The code snippet is

HashMap vMap = new HashMap();
vMap.put("projectName", modelFile.getProject().getName());
vMap.put("fileName", modelFile.getName() + "-strutsconfig.xml");
JET2Context context = new JET2Context(StrutsConfigType.class);
context.setVariables(vMap);
System.out.println("Artifact to be generated for "
+ modelFile.getName());
// TODO attach a progress monitor
IStatus transformStatus = JET2Platform.runTransformOnResource(
STRUTS_CONFIG_FILE_TRANSFORMER, modelFile,
new NullProgressMonitor());
if (transformStatus.isOK()) {
IStatus status = JET2Platform.runTransform(
STRUTS_CONFIG_FILE_TRANSFORMER, context,)
.......

i need to access the vMap variables in the main.jet

<%@taglib prefix="ws" id="org.eclipse.jet.workspaceTags" %>
<c:setVariable var="vProjectName" select="{$projectName"/>

Thanks in advance .

Regards,
Kamesh
Re: Access JET Conext variables in jet [message #51461 is a reply to message #51294] Thu, 21 September 2006 12:52 Go to previous messageGo to next message
Paul Elder is currently offline Paul ElderFriend
Messages: 849
Registered: July 2009
Senior Member
Kamesh:

There is a variant of runTransformOnResource that takes a map

Map vMap = new HashMap();
vMap.put("projectName", modelFile.getProject().getName());
vMap.put("fileName", modelFile.getName() + "-strutsconfig.xml");

IStatus status = JET2Platform.runTransformOnResource(
STRUTS_CONFIG_FILE_TRANSFORMER, modelFile, vMap, new NullProgressMonitor());

Your templates should then be able to get the variables in XPath expressions
such as:

<ws:project name="{$projectName}"/>

Also note that runTransformOnResource predefines a number of JET variables
derived from the resource name. All the names are prefixed with
org.eclipse.jet.resource, and then follow the IResource getter names. For
example:

org.eclipse.jet.resource.project.name

is the same as your variable $projectName. You can see all the variables
defined by viewing the Java doc for

org.eclipse.jet.taglib.workspace.WorkspaceContextExtender.lo adResourceAsSource()

Next, you should consider doing the calculation of 'projectName' and
'fileName' directly in your main.jet template. Based what I see in your
examples, it is part of your transformation proper. The following in
main.jet should work, assuming your invoke with
runTransformationOnResource():

<c:setVariable var="projectName"
select="$org.eclipse.jet.resource.project.name" />
<c:setVariable var="fileName" select="concat($org.eclipse.jet.resource.name,
'-structsconfig.xml')" />

Lastly, I notice your example has:

<c:setVariable var="vProjectName" select="{$projectName"/>

In general, you do not need (or want) the { and } braces in XPath
expressions for attributes named 'select' and 'test'. The tag handlers are
already expecting XPath expressions. In other attributes, the { and }
deliniate XPath expressions which are evaluated and converted to strings
prior to passing the attribute value to the tag handler.

In your case, <c:setVariable var="vProjectName" select="{$projectName}"/>
would likely result in an XPath parse error, because the setVariable tag
handler would try to interpret the VALUE of $projectName as an XPath
expression.

Paul Elder
JET Lead

"Kamesh Sampath" <kamesh_sampath@msn.com> wrote in message
news:eers14$rkp$1@utils.eclipse.org...
> Hi ,
>
> how to access the passVariables that I have passed from the JETContext
> inside the *.jet files.
>
> The code snippet is
>
> HashMap vMap = new HashMap();
> vMap.put("projectName", modelFile.getProject().getName());
> vMap.put("fileName", modelFile.getName() + "-strutsconfig.xml");
> JET2Context context = new JET2Context(StrutsConfigType.class);
> context.setVariables(vMap);
> System.out.println("Artifact to be generated for "
> + modelFile.getName());
> // TODO attach a progress monitor
> IStatus transformStatus = JET2Platform.runTransformOnResource(
> STRUTS_CONFIG_FILE_TRANSFORMER, modelFile,
> new NullProgressMonitor());
> if (transformStatus.isOK()) {
> IStatus status = JET2Platform.runTransform(
> STRUTS_CONFIG_FILE_TRANSFORMER, context,)
> ......
>
> i need to access the vMap variables in the main.jet
>
> <%@taglib prefix="ws" id="org.eclipse.jet.workspaceTags" %>
> <c:setVariable var="vProjectName" select="{$projectName"/>
>
> Thanks in advance .
>
> Regards,
> Kamesh
>
Re: Access JET Conext variables in jet [message #51737 is a reply to message #51461] Thu, 21 September 2006 17:37 Go to previous messageGo to next message
Kamesh Sampath is currently offline Kamesh SampathFriend
Messages: 191
Registered: July 2009
Senior Member
Paul Elder wrote:
> Kamesh:
>
> There is a variant of runTransformOnResource that takes a map
>
> Map vMap = new HashMap();
> vMap.put("projectName", modelFile.getProject().getName());
> vMap.put("fileName", modelFile.getName() + "-strutsconfig.xml");
>
> IStatus status = JET2Platform.runTransformOnResource(
> STRUTS_CONFIG_FILE_TRANSFORMER, modelFile, vMap, new NullProgressMonitor());
>
> Your templates should then be able to get the variables in XPath expressions
> such as:
>
> <ws:project name="{$projectName}"/>
>
> Also note that runTransformOnResource predefines a number of JET variables
> derived from the resource name. All the names are prefixed with
> org.eclipse.jet.resource, and then follow the IResource getter names. For
> example:
>
> org.eclipse.jet.resource.project.name
>
> is the same as your variable $projectName. You can see all the variables
> defined by viewing the Java doc for
>
> org.eclipse.jet.taglib.workspace.WorkspaceContextExtender.lo adResourceAsSource()
>
> Next, you should consider doing the calculation of 'projectName' and
> 'fileName' directly in your main.jet template. Based what I see in your
> examples, it is part of your transformation proper. The following in
> main.jet should work, assuming your invoke with
> runTransformationOnResource():
>
> <c:setVariable var="projectName"
> select="$org.eclipse.jet.resource.project.name" />
> <c:setVariable var="fileName" select="concat($org.eclipse.jet.resource.name,
> '-structsconfig.xml')" />
>
> Lastly, I notice your example has:
>
> <c:setVariable var="vProjectName" select="{$projectName"/>
>
> In general, you do not need (or want) the { and } braces in XPath
> expressions for attributes named 'select' and 'test'. The tag handlers are
> already expecting XPath expressions. In other attributes, the { and }
> deliniate XPath expressions which are evaluated and converted to strings
> prior to passing the attribute value to the tag handler.
>
> In your case, <c:setVariable var="vProjectName" select="{$projectName}"/>
> would likely result in an XPath parse error, because the setVariable tag
> handler would try to interpret the VALUE of $projectName as an XPath
> expression.
>
> Paul Elder
> JET Lead
>
> "Kamesh Sampath" <kamesh_sampath@msn.com> wrote in message
> news:eers14$rkp$1@utils.eclipse.org...
>> Hi ,
>>
>> how to access the passVariables that I have passed from the JETContext
>> inside the *.jet files.
>>
>> The code snippet is
>>
>> HashMap vMap = new HashMap();
>> vMap.put("projectName", modelFile.getProject().getName());
>> vMap.put("fileName", modelFile.getName() + "-strutsconfig.xml");
>> JET2Context context = new JET2Context(StrutsConfigType.class);
>> context.setVariables(vMap);
>> System.out.println("Artifact to be generated for "
>> + modelFile.getName());
>> // TODO attach a progress monitor
>> IStatus transformStatus = JET2Platform.runTransformOnResource(
>> STRUTS_CONFIG_FILE_TRANSFORMER, modelFile,
>> new NullProgressMonitor());
>> if (transformStatus.isOK()) {
>> IStatus status = JET2Platform.runTransform(
>> STRUTS_CONFIG_FILE_TRANSFORMER, context,)
>> ......
>>
>> i need to access the vMap variables in the main.jet
>>
>> <%@taglib prefix="ws" id="org.eclipse.jet.workspaceTags" %>
>> <c:setVariable var="vProjectName" select="{$projectName"/>
>>
>> Thanks in advance .
>>
>> Regards,
>> Kamesh
>>
>
Paul,
Thanks for your help will try incorporating the same and let you know.
The last error w.r.t {} was due to a typo as per the JET documentation
am using {$variableName} to access all the variables.

Thanks once again for the early response.

Regards,
Kamesh
Re: Access JET Conext variables in jet [message #52008 is a reply to message #51737] Fri, 22 September 2006 13:03 Go to previous messageGo to next message
Paul Elder is currently offline Paul ElderFriend
Messages: 849
Registered: July 2009
Senior Member
Kamesh:

If you find problems in the documentation, please submit bugzilla defects.
The following link will fill in most of the required information:

https://bugs.eclipse.org/bugs/enter_bug.cgi?product=EMFT& ;version=-&component=JET&rep_platform=PC&op_sys= Windows%20XP&priority=P3&bug_severity=normal&bug _status=NEW&assigned_to=pelder%40ca.ibm.com&qa_conta ct=&cc=&bug_file_loc=http%3A%2F%2F&short_desc=&a mp;comment=&commentprivacy=0&keywords=&dependson =&blocked=&maketemplate=Remember%20values%20as%20boo kmarkable%20template&form_name=enter_bug

(The link is pretty ugly - I have it in my bookmarks.)

Paul

"Kamesh Sampath" <kamesh_sampath@msn.com> wrote in message
news:eeuil4$9bf$1@utils.eclipse.org...
> Paul Elder wrote:
>> Kamesh:
>>
>> There is a variant of runTransformOnResource that takes a map
>>
>> Map vMap = new HashMap();
>> vMap.put("projectName", modelFile.getProject().getName());
>> vMap.put("fileName", modelFile.getName() + "-strutsconfig.xml");
>>
>> IStatus status = JET2Platform.runTransformOnResource(
>> STRUTS_CONFIG_FILE_TRANSFORMER, modelFile, vMap, new
>> NullProgressMonitor());
>>
>> Your templates should then be able to get the variables in XPath
>> expressions such as:
>>
>> <ws:project name="{$projectName}"/>
>>
>> Also note that runTransformOnResource predefines a number of JET
>> variables derived from the resource name. All the names are prefixed with
>> org.eclipse.jet.resource, and then follow the IResource getter names. For
>> example:
>>
>> org.eclipse.jet.resource.project.name
>>
>> is the same as your variable $projectName. You can see all the variables
>> defined by viewing the Java doc for
>>
>> org.eclipse.jet.taglib.workspace.WorkspaceContextExtender.lo adResourceAsSource()
>>
>> Next, you should consider doing the calculation of 'projectName' and
>> 'fileName' directly in your main.jet template. Based what I see in your
>> examples, it is part of your transformation proper. The following in
>> main.jet should work, assuming your invoke with
>> runTransformationOnResource():
>>
>> <c:setVariable var="projectName"
>> select="$org.eclipse.jet.resource.project.name" />
>> <c:setVariable var="fileName"
>> select="concat($org.eclipse.jet.resource.name, '-structsconfig.xml')" />
>>
>> Lastly, I notice your example has:
>>
>> <c:setVariable var="vProjectName" select="{$projectName"/>
>>
>> In general, you do not need (or want) the { and } braces in XPath
>> expressions for attributes named 'select' and 'test'. The tag handlers
>> are already expecting XPath expressions. In other attributes, the { and }
>> deliniate XPath expressions which are evaluated and converted to strings
>> prior to passing the attribute value to the tag handler.
>>
>> In your case, <c:setVariable var="vProjectName" select="{$projectName}"/>
>> would likely result in an XPath parse error, because the setVariable tag
>> handler would try to interpret the VALUE of $projectName as an XPath
>> expression.
>>
>> Paul Elder
>> JET Lead
>>
>> "Kamesh Sampath" <kamesh_sampath@msn.com> wrote in message
>> news:eers14$rkp$1@utils.eclipse.org...
>>> Hi ,
>>>
>>> how to access the passVariables that I have passed from the JETContext
>>> inside the *.jet files.
>>>
>>> The code snippet is
>>>
>>> HashMap vMap = new HashMap();
>>> vMap.put("projectName", modelFile.getProject().getName());
>>> vMap.put("fileName", modelFile.getName() + "-strutsconfig.xml");
>>> JET2Context context = new JET2Context(StrutsConfigType.class);
>>> context.setVariables(vMap);
>>> System.out.println("Artifact to be generated for "
>>> + modelFile.getName());
>>> // TODO attach a progress monitor
>>> IStatus transformStatus = JET2Platform.runTransformOnResource(
>>> STRUTS_CONFIG_FILE_TRANSFORMER, modelFile,
>>> new NullProgressMonitor());
>>> if (transformStatus.isOK()) {
>>> IStatus status = JET2Platform.runTransform(
>>> STRUTS_CONFIG_FILE_TRANSFORMER, context,)
>>> ......
>>>
>>> i need to access the vMap variables in the main.jet
>>>
>>> <%@taglib prefix="ws" id="org.eclipse.jet.workspaceTags" %>
>>> <c:setVariable var="vProjectName" select="{$projectName"/>
>>>
>>> Thanks in advance .
>>>
>>> Regards,
>>> Kamesh
>>>
>>
> Paul,
> Thanks for your help will try incorporating the same and let you know. The
> last error w.r.t {} was due to a typo as per the JET documentation am
> using {$variableName} to access all the variables.
>
> Thanks once again for the early response.
>
> Regards,
> Kamesh
Re: Access JET Conext variables in jet [message #52059 is a reply to message #52008] Fri, 22 September 2006 13:29 Go to previous messageGo to next message
Kamesh Sampath is currently offline Kamesh SampathFriend
Messages: 191
Registered: July 2009
Senior Member
Paul Elder wrote:
> Kamesh:
>
> If you find problems in the documentation, please submit bugzilla defects.
> The following link will fill in most of the required information:
>
> https://bugs.eclipse.org/bugs/enter_bug.cgi?product=EMFT& ;version=-&component=JET&rep_platform=PC&op_sys= Windows%20XP&priority=P3&bug_severity=normal&bug _status=NEW&assigned_to=pelder%40ca.ibm.com&qa_conta ct=&cc=&bug_file_loc=http%3A%2F%2F&short_desc=&a mp;comment=&commentprivacy=0&keywords=&dependson =&blocked=&maketemplate=Remember%20values%20as%20boo kmarkable%20template&form_name=enter_bug
>
> (The link is pretty ugly - I have it in my bookmarks.)
>
> Paul
>
> "Kamesh Sampath" <kamesh_sampath@msn.com> wrote in message
> news:eeuil4$9bf$1@utils.eclipse.org...
>> Paul Elder wrote:
>>> Kamesh:
>>>
>>> There is a variant of runTransformOnResource that takes a map
>>>
>>> Map vMap = new HashMap();
>>> vMap.put("projectName", modelFile.getProject().getName());
>>> vMap.put("fileName", modelFile.getName() + "-strutsconfig.xml");
>>>
>>> IStatus status = JET2Platform.runTransformOnResource(
>>> STRUTS_CONFIG_FILE_TRANSFORMER, modelFile, vMap, new
>>> NullProgressMonitor());
>>>
>>> Your templates should then be able to get the variables in XPath
>>> expressions such as:
>>>
>>> <ws:project name="{$projectName}"/>
>>>
>>> Also note that runTransformOnResource predefines a number of JET
>>> variables derived from the resource name. All the names are prefixed with
>>> org.eclipse.jet.resource, and then follow the IResource getter names. For
>>> example:
>>>
>>> org.eclipse.jet.resource.project.name
>>>
>>> is the same as your variable $projectName. You can see all the variables
>>> defined by viewing the Java doc for
>>>
>>> org.eclipse.jet.taglib.workspace.WorkspaceContextExtender.lo adResourceAsSource()
>>>
>>> Next, you should consider doing the calculation of 'projectName' and
>>> 'fileName' directly in your main.jet template. Based what I see in your
>>> examples, it is part of your transformation proper. The following in
>>> main.jet should work, assuming your invoke with
>>> runTransformationOnResource():
>>>
>>> <c:setVariable var="projectName"
>>> select="$org.eclipse.jet.resource.project.name" />
>>> <c:setVariable var="fileName"
>>> select="concat($org.eclipse.jet.resource.name, '-structsconfig.xml')" />
>>>
>>> Lastly, I notice your example has:
>>>
>>> <c:setVariable var="vProjectName" select="{$projectName"/>
>>>
>>> In general, you do not need (or want) the { and } braces in XPath
>>> expressions for attributes named 'select' and 'test'. The tag handlers
>>> are already expecting XPath expressions. In other attributes, the { and }
>>> deliniate XPath expressions which are evaluated and converted to strings
>>> prior to passing the attribute value to the tag handler.
>>>
>>> In your case, <c:setVariable var="vProjectName" select="{$projectName}"/>
>>> would likely result in an XPath parse error, because the setVariable tag
>>> handler would try to interpret the VALUE of $projectName as an XPath
>>> expression.
>>>
>>> Paul Elder
>>> JET Lead
>>>
>>> "Kamesh Sampath" <kamesh_sampath@msn.com> wrote in message
>>> news:eers14$rkp$1@utils.eclipse.org...
>>>> Hi ,
>>>>
>>>> how to access the passVariables that I have passed from the JETContext
>>>> inside the *.jet files.
>>>>
>>>> The code snippet is
>>>>
>>>> HashMap vMap = new HashMap();
>>>> vMap.put("projectName", modelFile.getProject().getName());
>>>> vMap.put("fileName", modelFile.getName() + "-strutsconfig.xml");
>>>> JET2Context context = new JET2Context(StrutsConfigType.class);
>>>> context.setVariables(vMap);
>>>> System.out.println("Artifact to be generated for "
>>>> + modelFile.getName());
>>>> // TODO attach a progress monitor
>>>> IStatus transformStatus = JET2Platform.runTransformOnResource(
>>>> STRUTS_CONFIG_FILE_TRANSFORMER, modelFile,
>>>> new NullProgressMonitor());
>>>> if (transformStatus.isOK()) {
>>>> IStatus status = JET2Platform.runTransform(
>>>> STRUTS_CONFIG_FILE_TRANSFORMER, context,)
>>>> ......
>>>>
>>>> i need to access the vMap variables in the main.jet
>>>>
>>>> <%@taglib prefix="ws" id="org.eclipse.jet.workspaceTags" %>
>>>> <c:setVariable var="vProjectName" select="{$projectName"/>
>>>>
>>>> Thanks in advance .
>>>>
>>>> Regards,
>>>> Kamesh
>>>>
>> Paul,
>> Thanks for your help will try incorporating the same and let you know. The
>> last error w.r.t {} was due to a typo as per the JET documentation am
>> using {$variableName} to access all the variables.
>>
>> Thanks once again for the early response.
>>
>> Regards,
>> Kamesh
>
>thanks paul !

By the way am planning to contribute an article to Eclipse on EMF and
JET transformations , all your valuable inputs are required . Please let
me know i can post some questions to you personally ( if you dont mind')

Regards,
Kamesh
Re: Access JET Conext variables in jet [message #52086 is a reply to message #52059] Fri, 22 September 2006 13:43 Go to previous messageGo to next message
Paul Elder is currently offline Paul ElderFriend
Messages: 849
Registered: July 2009
Senior Member
Kamesh:

I'd be pleased to answer any questions, and to review your article.

But, please post questions to the group - its a good way to share knowledge.
If you have a draft you'd like me to review, you can send it to me directly.

Paul

>>>>> snip!

> By the way am planning to contribute an article to Eclipse on EMF and JET
> transformations , all your valuable inputs are required . Please let me
> know i can post some questions to you personally ( if you dont mind')
>
> Regards,
> Kamesh
Re: Access JET Conext variables in jet [message #52141 is a reply to message #52086] Fri, 22 September 2006 13:51 Go to previous message
Kamesh Sampath is currently offline Kamesh SampathFriend
Messages: 191
Registered: July 2009
Senior Member
Paul Elder wrote:
> Kamesh:
>
> I'd be pleased to answer any questions, and to review your article.
>
> But, please post questions to the group - its a good way to share knowledge.
> If you have a draft you'd like me to review, you can send it to me directly.
>
> Paul
>
>>>>>> snip!
>
>> By the way am planning to contribute an article to Eclipse on EMF and JET
>> transformations , all your valuable inputs are required . Please let me
>> know i can post some questions to you personally ( if you dont mind')
>>
>> Regards,
>> Kamesh
>
>
thanks paul . will do that as you said sharing knowledge among all
newsgroup folks would be great. I have just started with the article
will dftnly send the article for your review once the draft is ready .
as JET2 lead you will know the flips and flops well .

Thanks for your courtesy.

Regards,
Kamesh
Re: Access JET Conext variables in jet [message #591563 is a reply to message #51294] Thu, 21 September 2006 12:52 Go to previous message
Paul Elder is currently offline Paul ElderFriend
Messages: 849
Registered: July 2009
Senior Member
Kamesh:

There is a variant of runTransformOnResource that takes a map

Map vMap = new HashMap();
vMap.put("projectName", modelFile.getProject().getName());
vMap.put("fileName", modelFile.getName() + "-strutsconfig.xml");

IStatus status = JET2Platform.runTransformOnResource(
STRUTS_CONFIG_FILE_TRANSFORMER, modelFile, vMap, new NullProgressMonitor());

Your templates should then be able to get the variables in XPath expressions
such as:

<ws:project name="{$projectName}"/>

Also note that runTransformOnResource predefines a number of JET variables
derived from the resource name. All the names are prefixed with
org.eclipse.jet.resource, and then follow the IResource getter names. For
example:

org.eclipse.jet.resource.project.name

is the same as your variable $projectName. You can see all the variables
defined by viewing the Java doc for

org.eclipse.jet.taglib.workspace.WorkspaceContextExtender.lo adResourceAsSource()

Next, you should consider doing the calculation of 'projectName' and
'fileName' directly in your main.jet template. Based what I see in your
examples, it is part of your transformation proper. The following in
main.jet should work, assuming your invoke with
runTransformationOnResource():

<c:setVariable var="projectName"
select="$org.eclipse.jet.resource.project.name" />
<c:setVariable var="fileName" select="concat($org.eclipse.jet.resource.name,
'-structsconfig.xml')" />

Lastly, I notice your example has:

<c:setVariable var="vProjectName" select="{$projectName"/>

In general, you do not need (or want) the { and } braces in XPath
expressions for attributes named 'select' and 'test'. The tag handlers are
already expecting XPath expressions. In other attributes, the { and }
deliniate XPath expressions which are evaluated and converted to strings
prior to passing the attribute value to the tag handler.

In your case, <c:setVariable var="vProjectName" select="{$projectName}"/>
would likely result in an XPath parse error, because the setVariable tag
handler would try to interpret the VALUE of $projectName as an XPath
expression.

Paul Elder
JET Lead

"Kamesh Sampath" <kamesh_sampath@msn.com> wrote in message
news:eers14$rkp$1@utils.eclipse.org...
> Hi ,
>
> how to access the passVariables that I have passed from the JETContext
> inside the *.jet files.
>
> The code snippet is
>
> HashMap vMap = new HashMap();
> vMap.put("projectName", modelFile.getProject().getName());
> vMap.put("fileName", modelFile.getName() + "-strutsconfig.xml");
> JET2Context context = new JET2Context(StrutsConfigType.class);
> context.setVariables(vMap);
> System.out.println("Artifact to be generated for "
> + modelFile.getName());
> // TODO attach a progress monitor
> IStatus transformStatus = JET2Platform.runTransformOnResource(
> STRUTS_CONFIG_FILE_TRANSFORMER, modelFile,
> new NullProgressMonitor());
> if (transformStatus.isOK()) {
> IStatus status = JET2Platform.runTransform(
> STRUTS_CONFIG_FILE_TRANSFORMER, context,)
> ......
>
> i need to access the vMap variables in the main.jet
>
> <%@taglib prefix="ws" id="org.eclipse.jet.workspaceTags" %>
> <c:setVariable var="vProjectName" select="{$projectName"/>
>
> Thanks in advance .
>
> Regards,
> Kamesh
>
Re: Access JET Conext variables in jet [message #591672 is a reply to message #51461] Thu, 21 September 2006 17:37 Go to previous message
Kamesh Sampath is currently offline Kamesh SampathFriend
Messages: 191
Registered: July 2009
Senior Member
Paul Elder wrote:
> Kamesh:
>
> There is a variant of runTransformOnResource that takes a map
>
> Map vMap = new HashMap();
> vMap.put("projectName", modelFile.getProject().getName());
> vMap.put("fileName", modelFile.getName() + "-strutsconfig.xml");
>
> IStatus status = JET2Platform.runTransformOnResource(
> STRUTS_CONFIG_FILE_TRANSFORMER, modelFile, vMap, new NullProgressMonitor());
>
> Your templates should then be able to get the variables in XPath expressions
> such as:
>
> <ws:project name="{$projectName}"/>
>
> Also note that runTransformOnResource predefines a number of JET variables
> derived from the resource name. All the names are prefixed with
> org.eclipse.jet.resource, and then follow the IResource getter names. For
> example:
>
> org.eclipse.jet.resource.project.name
>
> is the same as your variable $projectName. You can see all the variables
> defined by viewing the Java doc for
>
> org.eclipse.jet.taglib.workspace.WorkspaceContextExtender.lo adResourceAsSource()
>
> Next, you should consider doing the calculation of 'projectName' and
> 'fileName' directly in your main.jet template. Based what I see in your
> examples, it is part of your transformation proper. The following in
> main.jet should work, assuming your invoke with
> runTransformationOnResource():
>
> <c:setVariable var="projectName"
> select="$org.eclipse.jet.resource.project.name" />
> <c:setVariable var="fileName" select="concat($org.eclipse.jet.resource.name,
> '-structsconfig.xml')" />
>
> Lastly, I notice your example has:
>
> <c:setVariable var="vProjectName" select="{$projectName"/>
>
> In general, you do not need (or want) the { and } braces in XPath
> expressions for attributes named 'select' and 'test'. The tag handlers are
> already expecting XPath expressions. In other attributes, the { and }
> deliniate XPath expressions which are evaluated and converted to strings
> prior to passing the attribute value to the tag handler.
>
> In your case, <c:setVariable var="vProjectName" select="{$projectName}"/>
> would likely result in an XPath parse error, because the setVariable tag
> handler would try to interpret the VALUE of $projectName as an XPath
> expression.
>
> Paul Elder
> JET Lead
>
> "Kamesh Sampath" <kamesh_sampath@msn.com> wrote in message
> news:eers14$rkp$1@utils.eclipse.org...
>> Hi ,
>>
>> how to access the passVariables that I have passed from the JETContext
>> inside the *.jet files.
>>
>> The code snippet is
>>
>> HashMap vMap = new HashMap();
>> vMap.put("projectName", modelFile.getProject().getName());
>> vMap.put("fileName", modelFile.getName() + "-strutsconfig.xml");
>> JET2Context context = new JET2Context(StrutsConfigType.class);
>> context.setVariables(vMap);
>> System.out.println("Artifact to be generated for "
>> + modelFile.getName());
>> // TODO attach a progress monitor
>> IStatus transformStatus = JET2Platform.runTransformOnResource(
>> STRUTS_CONFIG_FILE_TRANSFORMER, modelFile,
>> new NullProgressMonitor());
>> if (transformStatus.isOK()) {
>> IStatus status = JET2Platform.runTransform(
>> STRUTS_CONFIG_FILE_TRANSFORMER, context,)
>> ......
>>
>> i need to access the vMap variables in the main.jet
>>
>> <%@taglib prefix="ws" id="org.eclipse.jet.workspaceTags" %>
>> <c:setVariable var="vProjectName" select="{$projectName"/>
>>
>> Thanks in advance .
>>
>> Regards,
>> Kamesh
>>
>
Paul,
Thanks for your help will try incorporating the same and let you know.
The last error w.r.t {} was due to a typo as per the JET documentation
am using {$variableName} to access all the variables.

Thanks once again for the early response.

Regards,
Kamesh
Re: Access JET Conext variables in jet [message #591747 is a reply to message #51737] Fri, 22 September 2006 13:03 Go to previous message
Paul Elder is currently offline Paul ElderFriend
Messages: 849
Registered: July 2009
Senior Member
Kamesh:

If you find problems in the documentation, please submit bugzilla defects.
The following link will fill in most of the required information:

https://bugs.eclipse.org/bugs/enter_bug.cgi?product=EMFT& ;version=-&component=JET&rep_platform=PC&op_sys= Windows%20XP&priority=P3&bug_severity=normal&bug _status=NEW&assigned_to=pelder%40ca.ibm.com&qa_conta ct=&cc=&bug_file_loc=http%3A%2F%2F&short_desc=&a mp;comment=&commentprivacy=0&keywords=&dependson =&blocked=&maketemplate=Remember%20values%20as%20boo kmarkable%20template&form_name=enter_bug

(The link is pretty ugly - I have it in my bookmarks.)

Paul

"Kamesh Sampath" <kamesh_sampath@msn.com> wrote in message
news:eeuil4$9bf$1@utils.eclipse.org...
> Paul Elder wrote:
>> Kamesh:
>>
>> There is a variant of runTransformOnResource that takes a map
>>
>> Map vMap = new HashMap();
>> vMap.put("projectName", modelFile.getProject().getName());
>> vMap.put("fileName", modelFile.getName() + "-strutsconfig.xml");
>>
>> IStatus status = JET2Platform.runTransformOnResource(
>> STRUTS_CONFIG_FILE_TRANSFORMER, modelFile, vMap, new
>> NullProgressMonitor());
>>
>> Your templates should then be able to get the variables in XPath
>> expressions such as:
>>
>> <ws:project name="{$projectName}"/>
>>
>> Also note that runTransformOnResource predefines a number of JET
>> variables derived from the resource name. All the names are prefixed with
>> org.eclipse.jet.resource, and then follow the IResource getter names. For
>> example:
>>
>> org.eclipse.jet.resource.project.name
>>
>> is the same as your variable $projectName. You can see all the variables
>> defined by viewing the Java doc for
>>
>> org.eclipse.jet.taglib.workspace.WorkspaceContextExtender.lo adResourceAsSource()
>>
>> Next, you should consider doing the calculation of 'projectName' and
>> 'fileName' directly in your main.jet template. Based what I see in your
>> examples, it is part of your transformation proper. The following in
>> main.jet should work, assuming your invoke with
>> runTransformationOnResource():
>>
>> <c:setVariable var="projectName"
>> select="$org.eclipse.jet.resource.project.name" />
>> <c:setVariable var="fileName"
>> select="concat($org.eclipse.jet.resource.name, '-structsconfig.xml')" />
>>
>> Lastly, I notice your example has:
>>
>> <c:setVariable var="vProjectName" select="{$projectName"/>
>>
>> In general, you do not need (or want) the { and } braces in XPath
>> expressions for attributes named 'select' and 'test'. The tag handlers
>> are already expecting XPath expressions. In other attributes, the { and }
>> deliniate XPath expressions which are evaluated and converted to strings
>> prior to passing the attribute value to the tag handler.
>>
>> In your case, <c:setVariable var="vProjectName" select="{$projectName}"/>
>> would likely result in an XPath parse error, because the setVariable tag
>> handler would try to interpret the VALUE of $projectName as an XPath
>> expression.
>>
>> Paul Elder
>> JET Lead
>>
>> "Kamesh Sampath" <kamesh_sampath@msn.com> wrote in message
>> news:eers14$rkp$1@utils.eclipse.org...
>>> Hi ,
>>>
>>> how to access the passVariables that I have passed from the JETContext
>>> inside the *.jet files.
>>>
>>> The code snippet is
>>>
>>> HashMap vMap = new HashMap();
>>> vMap.put("projectName", modelFile.getProject().getName());
>>> vMap.put("fileName", modelFile.getName() + "-strutsconfig.xml");
>>> JET2Context context = new JET2Context(StrutsConfigType.class);
>>> context.setVariables(vMap);
>>> System.out.println("Artifact to be generated for "
>>> + modelFile.getName());
>>> // TODO attach a progress monitor
>>> IStatus transformStatus = JET2Platform.runTransformOnResource(
>>> STRUTS_CONFIG_FILE_TRANSFORMER, modelFile,
>>> new NullProgressMonitor());
>>> if (transformStatus.isOK()) {
>>> IStatus status = JET2Platform.runTransform(
>>> STRUTS_CONFIG_FILE_TRANSFORMER, context,)
>>> ......
>>>
>>> i need to access the vMap variables in the main.jet
>>>
>>> <%@taglib prefix="ws" id="org.eclipse.jet.workspaceTags" %>
>>> <c:setVariable var="vProjectName" select="{$projectName"/>
>>>
>>> Thanks in advance .
>>>
>>> Regards,
>>> Kamesh
>>>
>>
> Paul,
> Thanks for your help will try incorporating the same and let you know. The
> last error w.r.t {} was due to a typo as per the JET documentation am
> using {$variableName} to access all the variables.
>
> Thanks once again for the early response.
>
> Regards,
> Kamesh
Re: Access JET Conext variables in jet [message #591755 is a reply to message #52008] Fri, 22 September 2006 13:29 Go to previous message
Kamesh Sampath is currently offline Kamesh SampathFriend
Messages: 191
Registered: July 2009
Senior Member
Paul Elder wrote:
> Kamesh:
>
> If you find problems in the documentation, please submit bugzilla defects.
> The following link will fill in most of the required information:
>
> https://bugs.eclipse.org/bugs/enter_bug.cgi?product=EMFT& ;version=-&component=JET&rep_platform=PC&op_sys= Windows%20XP&priority=P3&bug_severity=normal&bug _status=NEW&assigned_to=pelder%40ca.ibm.com&qa_conta ct=&cc=&bug_file_loc=http%3A%2F%2F&short_desc=&a mp;comment=&commentprivacy=0&keywords=&dependson =&blocked=&maketemplate=Remember%20values%20as%20boo kmarkable%20template&form_name=enter_bug
>
> (The link is pretty ugly - I have it in my bookmarks.)
>
> Paul
>
> "Kamesh Sampath" <kamesh_sampath@msn.com> wrote in message
> news:eeuil4$9bf$1@utils.eclipse.org...
>> Paul Elder wrote:
>>> Kamesh:
>>>
>>> There is a variant of runTransformOnResource that takes a map
>>>
>>> Map vMap = new HashMap();
>>> vMap.put("projectName", modelFile.getProject().getName());
>>> vMap.put("fileName", modelFile.getName() + "-strutsconfig.xml");
>>>
>>> IStatus status = JET2Platform.runTransformOnResource(
>>> STRUTS_CONFIG_FILE_TRANSFORMER, modelFile, vMap, new
>>> NullProgressMonitor());
>>>
>>> Your templates should then be able to get the variables in XPath
>>> expressions such as:
>>>
>>> <ws:project name="{$projectName}"/>
>>>
>>> Also note that runTransformOnResource predefines a number of JET
>>> variables derived from the resource name. All the names are prefixed with
>>> org.eclipse.jet.resource, and then follow the IResource getter names. For
>>> example:
>>>
>>> org.eclipse.jet.resource.project.name
>>>
>>> is the same as your variable $projectName. You can see all the variables
>>> defined by viewing the Java doc for
>>>
>>> org.eclipse.jet.taglib.workspace.WorkspaceContextExtender.lo adResourceAsSource()
>>>
>>> Next, you should consider doing the calculation of 'projectName' and
>>> 'fileName' directly in your main.jet template. Based what I see in your
>>> examples, it is part of your transformation proper. The following in
>>> main.jet should work, assuming your invoke with
>>> runTransformationOnResource():
>>>
>>> <c:setVariable var="projectName"
>>> select="$org.eclipse.jet.resource.project.name" />
>>> <c:setVariable var="fileName"
>>> select="concat($org.eclipse.jet.resource.name, '-structsconfig.xml')" />
>>>
>>> Lastly, I notice your example has:
>>>
>>> <c:setVariable var="vProjectName" select="{$projectName"/>
>>>
>>> In general, you do not need (or want) the { and } braces in XPath
>>> expressions for attributes named 'select' and 'test'. The tag handlers
>>> are already expecting XPath expressions. In other attributes, the { and }
>>> deliniate XPath expressions which are evaluated and converted to strings
>>> prior to passing the attribute value to the tag handler.
>>>
>>> In your case, <c:setVariable var="vProjectName" select="{$projectName}"/>
>>> would likely result in an XPath parse error, because the setVariable tag
>>> handler would try to interpret the VALUE of $projectName as an XPath
>>> expression.
>>>
>>> Paul Elder
>>> JET Lead
>>>
>>> "Kamesh Sampath" <kamesh_sampath@msn.com> wrote in message
>>> news:eers14$rkp$1@utils.eclipse.org...
>>>> Hi ,
>>>>
>>>> how to access the passVariables that I have passed from the JETContext
>>>> inside the *.jet files.
>>>>
>>>> The code snippet is
>>>>
>>>> HashMap vMap = new HashMap();
>>>> vMap.put("projectName", modelFile.getProject().getName());
>>>> vMap.put("fileName", modelFile.getName() + "-strutsconfig.xml");
>>>> JET2Context context = new JET2Context(StrutsConfigType.class);
>>>> context.setVariables(vMap);
>>>> System.out.println("Artifact to be generated for "
>>>> + modelFile.getName());
>>>> // TODO attach a progress monitor
>>>> IStatus transformStatus = JET2Platform.runTransformOnResource(
>>>> STRUTS_CONFIG_FILE_TRANSFORMER, modelFile,
>>>> new NullProgressMonitor());
>>>> if (transformStatus.isOK()) {
>>>> IStatus status = JET2Platform.runTransform(
>>>> STRUTS_CONFIG_FILE_TRANSFORMER, context,)
>>>> ......
>>>>
>>>> i need to access the vMap variables in the main.jet
>>>>
>>>> <%@taglib prefix="ws" id="org.eclipse.jet.workspaceTags" %>
>>>> <c:setVariable var="vProjectName" select="{$projectName"/>
>>>>
>>>> Thanks in advance .
>>>>
>>>> Regards,
>>>> Kamesh
>>>>
>> Paul,
>> Thanks for your help will try incorporating the same and let you know. The
>> last error w.r.t {} was due to a typo as per the JET documentation am
>> using {$variableName} to access all the variables.
>>
>> Thanks once again for the early response.
>>
>> Regards,
>> Kamesh
>
>thanks paul !

By the way am planning to contribute an article to Eclipse on EMF and
JET transformations , all your valuable inputs are required . Please let
me know i can post some questions to you personally ( if you dont mind')

Regards,
Kamesh
Re: Access JET Conext variables in jet [message #591759 is a reply to message #52059] Fri, 22 September 2006 13:43 Go to previous message
Paul Elder is currently offline Paul ElderFriend
Messages: 849
Registered: July 2009
Senior Member
Kamesh:

I'd be pleased to answer any questions, and to review your article.

But, please post questions to the group - its a good way to share knowledge.
If you have a draft you'd like me to review, you can send it to me directly.

Paul

>>>>> snip!

> By the way am planning to contribute an article to Eclipse on EMF and JET
> transformations , all your valuable inputs are required . Please let me
> know i can post some questions to you personally ( if you dont mind')
>
> Regards,
> Kamesh
Re: Access JET Conext variables in jet [message #591780 is a reply to message #52086] Fri, 22 September 2006 13:51 Go to previous message
Kamesh Sampath is currently offline Kamesh SampathFriend
Messages: 191
Registered: July 2009
Senior Member
Paul Elder wrote:
> Kamesh:
>
> I'd be pleased to answer any questions, and to review your article.
>
> But, please post questions to the group - its a good way to share knowledge.
> If you have a draft you'd like me to review, you can send it to me directly.
>
> Paul
>
>>>>>> snip!
>
>> By the way am planning to contribute an article to Eclipse on EMF and JET
>> transformations , all your valuable inputs are required . Please let me
>> know i can post some questions to you personally ( if you dont mind')
>>
>> Regards,
>> Kamesh
>
>
thanks paul . will do that as you said sharing knowledge among all
newsgroup folks would be great. I have just started with the article
will dftnly send the article for your review once the draft is ready .
as JET2 lead you will know the flips and flops well .

Thanks for your courtesy.

Regards,
Kamesh
Previous Topic:passing multiple variables in JET2 control tag <c:iterate>
Next Topic:Teneo: storing custom EDataType attributes (i.e. java.io.File)
Goto Forum:
  


Current Time: Fri Apr 26 04:50:07 GMT 2024

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

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

Back to the top