Bug 14465 - position() and last() are critical
Summary: position() and last() are critical
Alias: None
Product: Taglibs
Classification: Unclassified
Component: Standard Taglib (show other bugs)
Version: 1.0
Hardware: Other All
: P3 critical (vote)
Target Milestone: ---
Assignee: Tomcat Developers Mailing List
: 14687 15483 22765 (view as bug list)
Depends on:
Reported: 2002-11-12 04:51 UTC by James Lewis
Modified: 2010-12-31 18:24 UTC (History)
3 users (show)


Note You need to log in before you can comment on or make changes to this bug.
Description James Lewis 2002-11-12 04:51:38 UTC
The expressions last() and position() both return 0 in every iteration of a 
forEach tag.  It is real hard to develop a JSTL app without these expressions 
working.  When will this be fixed?  Below is a simple example that will 
demonstrate the problem:

<%@ taglib uri="http://java.sun.com/jstl/xml" prefix="x" %>
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>




<x:parse var="xml">
	<?xml version="1.0" encoding="ISO-8859-1"?>

<x:forEach select="$xml/root/name">
	<x:out select="first"/>
	<x:out select="position()"/>

In this example the position() returns '0' every time.
Comment 1 Shawn Bayern 2002-11-12 12:32:48 UTC
This isn't a bug in the implementation; I believe it requires additional 
support from the JSTL specification before being implemented.  In particular, 
the following definitions would need to be added:

I believe it would involve adding definitions to the
spec along the following lines:

 Inside the body of the <x:forEach> tag, the context for XPath expression
 evaluations is obtained as follows:

  * variable, function, and namespace bindings operate as in the rest of
  * the context node is the node whose representation would be exposed by
    'var' (whether or not the 'var' attribute is specified)
  * the context position is the iteration 'count' (with the same meaning
    as in <c:forEach>)
  * the context size is equal to the number of nodes in the node-set
    over which <x:forEach> is presently iterating.

We're also considering adding varStatus, which would provide an alternative 
mechanism for achieving the same result.

Just because I'm marking this "INVALID" here doesn't mean it's not important; 
I'm just noting that it's not an implementation issue.  (This bug-tracking 
system is just for implementation issues.)
Comment 2 Pierre Delisle 2002-12-04 01:11:59 UTC
*** Bug 14687 has been marked as a duplicate of this bug. ***
Comment 3 Pierre Delisle 2002-12-18 14:49:37 UTC
*** Bug 15483 has been marked as a duplicate of this bug. ***
Comment 4 Jeremy Boynes 2010-12-31 18:23:10 UTC
Fixed with XPath refactoring in r1054175
Comment 5 Jeremy Boynes 2010-12-31 18:24:00 UTC
*** Bug 22765 has been marked as a duplicate of this bug. ***