Eclipse Community Forums - RDF feed
https://www.eclipse.org/forums/
Eclipse Community Forumserror on context.getVariable
https://www.eclipse.org/forums/index.php/mv/msg/19963/64137/#msg_64137
...
<c:setVariable var="x0" select="$c/@name" />
<%
String x1 = (String) context.getVariable("x0");
String x2 = x1 + "_1.xml";
out.write(x2);
%>
The error message is:
Error executing tag handler: java.lang.ClassCastException:
org.eclipse.jet.internal.xpath.NodeSetImpl cannot be cast to
java.lang.String
What could be the cause of this error, and how could I solve it ?
Some background:
The JET template 'work.jet' gets as input an profile that specifies the
names of a set of (other) XML files that it loads inside a loop, and deals
with their content.
In 'main.jet' I have included a dump statement for the profile.
However I want to dump each of the XML files that are specified in the
profile.
For that reason I want (inside 'work.jet') to construct specific names for
these dump files.
Any help is very much appreciated.
Kind regards,
Aart Matsinger]]>aart matsinger2009-07-10T08:10:16-00:00Re: error on context.getVariable
https://www.eclipse.org/forums/index.php/mv/msg/19963/64182/#msg_64182
> The following construct in a JET transformation template gives an error:
> ...
> <c:setVariable var="x0" select="$c/@name" />
> <%
> String x1 = (String) context.getVariable("x0");
> String x2 = x1 + "_1.xml";
> out.write(x2);
> %>
> The error message is:
> Error executing tag handler: java.lang.ClassCastException:
> org.eclipse.jet.internal.xpath.NodeSetImpl cannot be cast to
> java.lang.String
Two suggestions:
1) The result of $c/@name is an XPath nodeset, not a string. You can
convert it to a string in one of two ways:
2) You don't need to drop into Java at all to do what you want! Simply
putting this expression into your template yields the same result:
${$c/@name)_1.xml
Or, if you are using a release earlier than 1.0, the slightly longer form
below is equivalent:
<c:get select="$c/@name"/>_1.xml
Paul]]>Paul Elder2009-07-10T13:16:59-00:00Re: error on context.getVariable
https://www.eclipse.org/forums/index.php/mv/msg/19963/64211/#msg_64211
Thanks for your help: I tried all alternatives and they are working fine,
except for the one that requires a version a version 1.
I found that I have for JET version 0.9.3 and for JET Core version 1.1.1,
so I assume that seems consistent with your statement.
I am struggling with the basics, so I am learning a lot in this way.