Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » How to get setVariable value back
How to get setVariable value back [message #8018] Wed, 28 March 2007 14:46 Go to next message
Eclipse UserFriend
Originally posted by: evaandoli.dodo.com.au

Using the setVariable seems to comes out blank when used later on.

I guessing its the way Im reading it back (using {} maybe).

Example Jet is below:

<c:setVariable var="className" select="HelloClass"/>

private {$className} <c:get select="lowercaseFirst($node/@tag)" />;
Re: How to get setVariable value back [message #8141 is a reply to message #8018] Thu, 29 March 2007 04:07 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: evaandoli.dodo.com.au

It seem a bit **** but I got this to work by doing:-
<c:addTextElement select="$node" name="nodeType"
var="nodeTypeText">HelloClass</c:addTextElement>
<c:get select="$nodeTypeText"/>

There is probably a better way so let me know if you find it.

On a slight follow on:-

I then did

private <java:import><c:get select="$nodeTypeText"/></java:import>

Which doesn't resolve the variable before the input statement (anyway that
is what I found) so I just went back to my BIG choose when statement I first
used before trying to be clever.




"Stu" <evaandoli@dodo.com.au> wrote in message
news:eudv42$v0c$1@utils.eclipse.org...
> Using the setVariable seems to comes out blank when used later on.
>
> I guessing its the way Im reading it back (using {} maybe).
>
> Example Jet is below:
>
> <c:setVariable var="className" select="HelloClass"/>
>
> private {$className} <c:get select="lowercaseFirst($node/@tag)" />;
>
>
>
>
>
Re: How to get setVariable value back [message #8330 is a reply to message #8018] Thu, 29 March 2007 13:01 Go to previous messageGo to next message
Paul Elder is currently offline Paul ElderFriend
Messages: 849
Registered: July 2009
Senior Member
Try:

private <c:get select="$className"/> <c:get
select="lowercaseFirst($node/@tag)" />;

Dynamic XPath expression {$className} only work within attributes of an JET
tag (since you can't but a tag with in a tag).

I am considering doing something like:

private {$className} <c:get select="lowercaseFirst($node/@tag)" />;

But I don't think I can safely use { and } as delimiters - they appear too
often in static text.

My favourite alternative at this point is:

private {{$className}} <c:get select="lowercaseFirst($node/@tag)" />;

I don't think I'll get it in for this release, though. I have submitted a
bugzilla on the idea (https://bugs.eclipse.org/bugs/show_bug.cgi?id=179978).
Feel free to add your comments.

Paul

"Stu" <evaandoli@dodo.com.au> wrote in message
news:eudv42$v0c$1@utils.eclipse.org...
> Using the setVariable seems to comes out blank when used later on.
>
> I guessing its the way Im reading it back (using {} maybe).
>
> Example Jet is below:
>
> <c:setVariable var="className" select="HelloClass"/>
>
> private {$className} <c:get select="lowercaseFirst($node/@tag)" />;
>
>
>
>
>
Re: How to get setVariable value back [message #8392 is a reply to message #8330] Thu, 29 March 2007 13:59 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: evaandoli.dodo.com.au

I had tried the <c:get /> :-
<c:setVariable var="className" select="HelloClass"/>

private <c:get select="$className"/>;

But get the following error:

templates/dump.jet(4,9): <c:get select="$className">

Error: XPath expression returned no result

Stuart

"Paul Elder" <pelder@ca.ibm.com> wrote in message
news:eugdb5$6rq$1@build.eclipse.org...
> Try:
>
> private <c:get select="$className"/> <c:get
> select="lowercaseFirst($node/@tag)" />;
>
> Dynamic XPath expression {$className} only work within attributes of an
> JET tag (since you can't but a tag with in a tag).
>
> I am considering doing something like:
>
> private {$className} <c:get select="lowercaseFirst($node/@tag)" />;
>
> But I don't think I can safely use { and } as delimiters - they appear too
> often in static text.
>
> My favourite alternative at this point is:
>
> private {{$className}} <c:get select="lowercaseFirst($node/@tag)" />;
>
> I don't think I'll get it in for this release, though. I have submitted a
> bugzilla on the idea
> (https://bugs.eclipse.org/bugs/show_bug.cgi?id=179978). Feel free to add
> your comments.
>
> Paul
>
> "Stu" <evaandoli@dodo.com.au> wrote in message
> news:eudv42$v0c$1@utils.eclipse.org...
>> Using the setVariable seems to comes out blank when used later on.
>>
>> I guessing its the way Im reading it back (using {} maybe).
>>
>> Example Jet is below:
>>
>> <c:setVariable var="className" select="HelloClass"/>
>>
>> private {$className} <c:get select="lowercaseFirst($node/@tag)" />;
>>
>>
>>
>>
>>
>
>
Re: How to get setVariable value back [message #8483 is a reply to message #8392] Fri, 30 March 2007 07:35 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: evaandoli.dodo.com.au

It also doesn;t work for choose statements so I assume a bug is in the
setVariable when its a containt.
This is a real hassle :-)

<c:setVariable var="returnedRuleType" select="String"/>

<c:choose>

<c:when test="$returnedRuleType='String'">

<c:log>We have a String</c:log>

</c:when>

</c:choose>


"Stu" <evaandoli@dodo.com.au> wrote in message
news:euggo6$vdf$1@build.eclipse.org...
>I had tried the <c:get /> :-
> <c:setVariable var="className" select="HelloClass"/>
>
> private <c:get select="$className"/>;
>
> But get the following error:
>
> templates/dump.jet(4,9): <c:get select="$className">
>
> Error: XPath expression returned no result
>
> Stuart
>
> "Paul Elder" <pelder@ca.ibm.com> wrote in message
> news:eugdb5$6rq$1@build.eclipse.org...
>> Try:
>>
>> private <c:get select="$className"/> <c:get
>> select="lowercaseFirst($node/@tag)" />;
>>
>> Dynamic XPath expression {$className} only work within attributes of an
>> JET tag (since you can't but a tag with in a tag).
>>
>> I am considering doing something like:
>>
>> private {$className} <c:get select="lowercaseFirst($node/@tag)" />;
>>
>> But I don't think I can safely use { and } as delimiters - they appear
>> too often in static text.
>>
>> My favourite alternative at this point is:
>>
>> private {{$className}} <c:get select="lowercaseFirst($node/@tag)" />;
>>
>> I don't think I'll get it in for this release, though. I have submitted a
>> bugzilla on the idea
>> (https://bugs.eclipse.org/bugs/show_bug.cgi?id=179978). Feel free to add
>> your comments.
>>
>> Paul
>>
>> "Stu" <evaandoli@dodo.com.au> wrote in message
>> news:eudv42$v0c$1@utils.eclipse.org...
>>> Using the setVariable seems to comes out blank when used later on.
>>>
>>> I guessing its the way Im reading it back (using {} maybe).
>>>
>>> Example Jet is below:
>>>
>>> <c:setVariable var="className" select="HelloClass"/>
>>>
>>> private {$className} <c:get select="lowercaseFirst($node/@tag)" />;
>>>
>>>
>>>
>>>
>>>
>>
>>
>
>
Re: How to get setVariable value back [message #8513 is a reply to message #8483] Fri, 30 March 2007 09:25 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: evaandoli.dodo.com.au

A quick work around for this is:-
<c:addTextElement select="$expression" name="string"
var="stringText">String</c:addTextElement>

<c:setVariable var="returnedRuleType" select="$stringText"/>

<c:removeElement select="$expression/string"/>

Off to get the headache tablets.



"Stu" <evaandoli@dodo.com.au> wrote in message
news:euieki$mae$1@build.eclipse.org...
> It also doesn;t work for choose statements so I assume a bug is in the
> setVariable when its a containt.
> This is a real hassle :-)
>
> <c:setVariable var="returnedRuleType" select="String"/>
>
> <c:choose>
>
> <c:when test="$returnedRuleType='String'">
>
> <c:log>We have a String</c:log>
>
> </c:when>
>
> </c:choose>
>
>
> "Stu" <evaandoli@dodo.com.au> wrote in message
> news:euggo6$vdf$1@build.eclipse.org...
>>I had tried the <c:get /> :-
>> <c:setVariable var="className" select="HelloClass"/>
>>
>> private <c:get select="$className"/>;
>>
>> But get the following error:
>>
>> templates/dump.jet(4,9): <c:get select="$className">
>>
>> Error: XPath expression returned no result
>>
>> Stuart
>>
>> "Paul Elder" <pelder@ca.ibm.com> wrote in message
>> news:eugdb5$6rq$1@build.eclipse.org...
>>> Try:
>>>
>>> private <c:get select="$className"/> <c:get
>>> select="lowercaseFirst($node/@tag)" />;
>>>
>>> Dynamic XPath expression {$className} only work within attributes of an
>>> JET tag (since you can't but a tag with in a tag).
>>>
>>> I am considering doing something like:
>>>
>>> private {$className} <c:get select="lowercaseFirst($node/@tag)" />;
>>>
>>> But I don't think I can safely use { and } as delimiters - they appear
>>> too often in static text.
>>>
>>> My favourite alternative at this point is:
>>>
>>> private {{$className}} <c:get select="lowercaseFirst($node/@tag)" />;
>>>
>>> I don't think I'll get it in for this release, though. I have submitted
>>> a bugzilla on the idea
>>> (https://bugs.eclipse.org/bugs/show_bug.cgi?id=179978). Feel free to add
>>> your comments.
>>>
>>> Paul
>>>
>>> "Stu" <evaandoli@dodo.com.au> wrote in message
>>> news:eudv42$v0c$1@utils.eclipse.org...
>>>> Using the setVariable seems to comes out blank when used later on.
>>>>
>>>> I guessing its the way Im reading it back (using {} maybe).
>>>>
>>>> Example Jet is below:
>>>>
>>>> <c:setVariable var="className" select="HelloClass"/>
>>>>
>>>> private {$className} <c:get select="lowercaseFirst($node/@tag)" />;
>>>>
>>>>
>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>
>
Re: How to get setVariable value back [message #9841 is a reply to message #8392] Mon, 02 April 2007 12:12 Go to previous message
Paul Elder is currently offline Paul ElderFriend
Messages: 849
Registered: July 2009
Senior Member
Stu:

A quick fix: a minor tweak to your code:

<%-- I added spaces in select= for clarity. The essentail difference is the
single quotes around 'HelloClass' --%>
<c:setVariable var="className" select=" 'HelloClass' "/>

An explanation: Without the single quotes, the XPath engine is evaluating
the expression HelloClass, which is equivalent to
../HelloClass. With JET, . maps to the "document", so this is equivalent to
/HelloClass. Odds are that you don't have
an element HelloClass at the root of you input, so className gets set to an
empty node set. The fix makes HelloClass a string - your code should now
work.

FYI: The XPath language can represent boolean, string and numeric values as
well as 'path expressions'. You can set XPath variables to contain any of
these:

<c:setVariable var="vNum" select=" 3 + 6"/>
<c:setVariable var="vString" select=" 'a String' "/>
<c:setVariable var="vBoolean" select=" 3 + 6 = 9 "/>

Paul

"Stu" <evaandoli@dodo.com.au> wrote in message
news:euggo6$vdf$1@build.eclipse.org...
>I had tried the <c:get /> :-
> <c:setVariable var="className" select="HelloClass"/>
>
> private <c:get select="$className"/>;
>
> But get the following error:
>
> templates/dump.jet(4,9): <c:get select="$className">
>
> Error: XPath expression returned no result
>
> Stuart
>
> "Paul Elder" <pelder@ca.ibm.com> wrote in message
> news:eugdb5$6rq$1@build.eclipse.org...
>> Try:
>>
>> private <c:get select="$className"/> <c:get
>> select="lowercaseFirst($node/@tag)" />;
>>
>> Dynamic XPath expression {$className} only work within attributes of an
>> JET tag (since you can't but a tag with in a tag).
>>
>> I am considering doing something like:
>>
>> private {$className} <c:get select="lowercaseFirst($node/@tag)" />;
>>
>> But I don't think I can safely use { and } as delimiters - they appear
>> too often in static text.
>>
>> My favourite alternative at this point is:
>>
>> private {{$className}} <c:get select="lowercaseFirst($node/@tag)" />;
>>
>> I don't think I'll get it in for this release, though. I have submitted a
>> bugzilla on the idea
>> (https://bugs.eclipse.org/bugs/show_bug.cgi?id=179978). Feel free to add
>> your comments.
>>
>> Paul
>>
>> "Stu" <evaandoli@dodo.com.au> wrote in message
>> news:eudv42$v0c$1@utils.eclipse.org...
>>> Using the setVariable seems to comes out blank when used later on.
>>>
>>> I guessing its the way Im reading it back (using {} maybe).
>>>
>>> Example Jet is below:
>>>
>>> <c:setVariable var="className" select="HelloClass"/>
>>>
>>> private {$className} <c:get select="lowercaseFirst($node/@tag)" />;
>>>
>>>
>>>
>>>
>>>
>>
>>
>
>
Previous Topic:Re: JET Null Pointer Exception & XPath Axes
Next Topic:Dynamic parameter for a java method defined in the jet file
Goto Forum:
  


Current Time: Tue Apr 16 10:58:44 GMT 2024

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

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

Back to the top