Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » why require a var definition in a loop?
why require a var definition in a loop? [message #39165] Thu, 10 January 2008 23:38 Go to next message
Felix Dorner is currently offline Felix DornerFriend
Messages: 676
Registered: July 2009
Senior Member
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 14:36 Go to previous messageGo to next message
Paul Elder is currently offline Paul ElderFriend
Messages: 849
Registered: July 2009
Senior Member
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 16:00 Go to previous message
Felix Dorner is currently offline Felix DornerFriend
Messages: 676
Registered: July 2009
Senior Member
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
Previous Topic:[JET] How to handle ident of multiple-line strings generated by a scriplet.
Next Topic:JET ws:file tag options for Japanese characters
Goto Forum:
  


Current Time: Thu Mar 28 23:37:24 GMT 2024

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

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

Back to the top