You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by Stephan Coboos <cr...@gmx.net> on 2004/04/18 18:30:10 UTC

#{//foo/bar} doesn't work within forEach!

Hello,

I've tried to retrieve an object within a JXTemplate:

#{//foo/bar}

This works fine outside any "forEach". If I'am using it inner forEach, 
nothing will be printed out:

<jx:forEach var="something" items="${myList}">

   #{//foo/bar}

</jx:forEach>

Because // refers to the root, the value should be printed out within 
this context, right? Whats wrong?

Thank you.

Regards
Stephan

Re: #{//foo/bar} doesn't work within forEach!

Posted by Stephan Coboos <cr...@gmx.net>.
Leon Widdershoven wrote:

> Could it be that you are using both Jexl and XPath tags?
>
Yes of course. But it should work, shouldn't it? Because something like 
this works, correctly:

<jx:forEach var="myItem" items="${myList}">

Item: #{.}

</jx:forEach>

Note: The iteration will be done by using Jexl. The node to print out 
will be selected by XPath.
So i think it is possible to mix Jexl and XPath.

Regards
Stephan




Re: #{//foo/bar} doesn't work within forEach!

Posted by Leon Widdershoven <qa...@dds.nl>.
Could it be that you are using both Jexl and XPath tags?

Stephan Coboos wrote:

> Hello,
>
> I've tried to retrieve an object within a JXTemplate:
>
> #{//foo/bar}
>
> This works fine outside any "forEach". If I'am using it inner forEach, 
> nothing will be printed out:
>
> <jx:forEach var="something" items="${myList}">
>
>   #{//foo/bar}
>
> </jx:forEach>
>
> Because // refers to the root, the value should be printed out within 
> this context, right? Whats wrong?
>
> Thank you.
>
> Regards
> Stephan



Re: #{//foo/bar} doesn't work within forEach!

Posted by Christopher Oliver <re...@verizon.net>.
No. That won't work. With the current implementation of JXTG XPath 
evaluation of absolute paths with a <forEach> only works if the 
expression passed to <forEach> is an XPath expression. Does this work:

<jx:forEach var="something" items="#{myList}">

  #{//foo/bar}

</jx:forEach>


Chris



Stephan Coboos wrote:

> Hello,
>
> I've tried to retrieve an object within a JXTemplate:
>
> #{//foo/bar}
>
> This works fine outside any "forEach". If I'am using it inner forEach, 
> nothing will be printed out:
>
> <jx:forEach var="something" items="${myList}">
>
>   #{//foo/bar}
>
> </jx:forEach>
>
> Because // refers to the root, the value should be printed out within 
> this context, right? Whats wrong?
>
> Thank you.
>
> Regards
> Stephan
>