why require a var definition in a loop? [message #39165] |
Thu, 10 January 2008 18:38  |
Eclipse User |
|
|
|
Hey,
a sample from the "create better code with jet article":
<c:iterate select="/app/person" var="currNode" delimiter="," >
Name = <c:get select="$currNode/@name" />
</c:iterate>
wouldnt it be cooler to have an implicit context node (I have seen this
in xpath/xslt or xquery, not sure...), like this:
<c:iterate select="/app/person delimiter="," >
<-- context is now a person node that has a name attribute -->
Name = <c:get select = @name>
</c:iterate>
This doesn't seem to work however.
Felix
|
|
|
Re: why require a var definition in a loop? [message #39783 is a reply to message #39165] |
Tue, 15 January 2008 09:36   |
Eclipse User |
|
|
|
Felix:
When I was designing the tags, I considered and rejected this. I decided
that readers of the template would then have to figure out the context of
many expressions by looking more widely at the template. My goal was to keep
JET templates really simple to understand, and after coding a number of
templates both ways, I decided that while changing the context resulted in
shorter XPath expressions, it also resulted in templates that seemed
considerably more mysterious.
If you feel strongly about having such a feature, feel free to submit a
bugzilla. Even better, attach a patch with the implementation.
But I wonder whether this is not so much about the compactness of the XPath
expression, and more about the verbosity of c:get? I have a submitted:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=179978
Which suggests have having something like {{$currNode/@name}} as an
alternative to <c:get select="$currNode/@name"/>. How would that effect
your view of the article's code?
Thanks for your interest,
Paul
"Felix Dorner" <felix_do@web.de> wrote in message
news:20080111003820.1ff8c8b3@serenity...
> Hey,
>
> a sample from the "create better code with jet article":
>
> <c:iterate select="/app/person" var="currNode" delimiter="," >
> Name = <c:get select="$currNode/@name" />
> </c:iterate>
>
> wouldnt it be cooler to have an implicit context node (I have seen this
> in xpath/xslt or xquery, not sure...), like this:
>
> <c:iterate select="/app/person delimiter="," >
> <-- context is now a person node that has a name attribute -->
> Name = <c:get select = @name>
> </c:iterate>
>
>
> This doesn't seem to work however.
>
>
>
> Felix
>
>
>
>
>
|
|
|
Re: why require a var definition in a loop? [message #40057 is a reply to message #39783] |
Tue, 15 January 2008 11:00  |
Eclipse User |
|
|
|
Hey Paul,
I understand, and maybe you are right - people might find it harder to
read bigger templates when operating on an implicit context node. As I
will probably use JET in an upcoming project I'll see if the syntax
really annoys me that much, I was just curious for now.
Felix
|
|
|
Powered by
FUDForum. Page generated in 0.05717 seconds