Bug 12620 - position() and last() do not work in xtags:template match attributes
Summary: position() and last() do not work in xtags:template match attributes
Status: RESOLVED LATER
Alias: None
Product: Taglibs
Classification: Unclassified
Component: XTags Taglib (show other bugs)
Version: unspecified
Hardware: Sun Solaris
: P3 normal with 1 vote (vote)
Target Milestone: ---
Assignee: Tomcat Developers Mailing List
URL:
Keywords:
: 29225 (view as bug list)
Depends on:
Blocks:
 
Reported: 2002-09-13 15:25 UTC by Dawn Roth
Modified: 2009-11-29 19:45 UTC (History)
1 user (show)



Attachments

Note You need to log in before you can comment on or make changes to this bug.
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.