Bug 12620

Summary: position() and last() do not work in xtags:template match attributes
Product: Taglibs Reporter: Dawn Roth <dawn.roth>
Component: XTags TaglibAssignee: Tomcat Developers Mailing List <dev>
Status: RESOLVED LATER    
Severity: normal CC: f.sabbatini
Priority: P3    
Version: unspecified   
Target Milestone: ---   
Hardware: Sun   
OS: Solaris   

Description Dawn Roth 2002-09-13 15:25:33 UTC
The position() and last() functions do not work in xtags:template match
attributes.  This means that you cannot match the last or specified item in a
record set.  You also can't match all of them and then test in the template if
the current one is last (or whichever position you are looking for) since the
functions do not work with <xtags:if test=""> either.  (I saw a bug report for
xtags:if and last/position, so I won't go into that more.)

None of these matches will work properly:
<xtags:template match="/root/item[last()]">
<xtags:template match="/root/item[position()=last()]">
<xtags:template match="/root/item[1]">
<xtags:template match="/root/item[position()=1]">

The position and last functions always return 0, so item[last()] and
item[position()=last()] match for every element, not just the last one.

The only way I have been able to get them to work is with <xtags:forEach> and
<xtags:context>, but this limited functionality is a very painful workaround. 
You also cannot use this workaround with the xtags:stylesheet & xtags:template
way of translating because the output comes out of order.

These mailing list mails also discuss problems with position and last:
http://www.mail-archive.com/taglibs-user@jakarta.apache.org/msg01506.html
http://www.mail-archive.com/taglibs-user@jakarta.apache.org/msg01778.html
http://www.mail-archive.com/taglibs-user@jakarta.apache.org/msg02505.html

Thanks very much,
Dawn Roth
Comment 1 Sven Rottenbiller 2004-08-23 21:00:27 UTC
*** Bug 29225 has been marked as a duplicate of this bug. ***
Comment 2 Henri Yandell 2009-11-29 19:45:03 UTC
Resolving. Taglib has been retired.