Ouch! This reveals a very nasty flaw in the approach to evaluating last(). Amazing that such a simple test case can reveal a problem that has been in the code for ever, and that runs pretty deep in the design. I'll need to think about this one quite carefully. Thanks for notifying it.
 
Michael Kay
Saxonica


From: saxon-help-bounces@lists.sourceforge.net [mailto:saxon-help-bounces@lists.sourceforge.net] On Behalf Of Rademacher, Gunther
Sent: 02 December 2007 21:43
To: saxon-help@lists.sourceforge.net
Subject: [saxon] XQuery last() value of positional variable

A wrong result is returned when a numeric predicate based on function
last() is applied to a sequence that was built from values of a positional
variable, e.g.

        (for $x at $i in (1, 2) return $i)[last()]
 
returns 4, but should be 2. Seems like the result is always doubled.

Best regards,
Gunther


Software AG – Sitz/Registered office: Uhlandstraße 12, 64297 Darmstadt, Germany, – Registergericht/Commercial register: Darmstadt HRB 1562 - Vorstand/ Management Board: Karl-Heinz Streibich (Vorsitzender/Chairman), David Broadbent, Mark Edwards, Dr. Peter Kürpick, David Mitchell, Arnd Zinnhardt; - Aufsichtsratsvorsitzender/ Chairman of the Supervisory Board: Frank F. Beelitz - http://www.softwareag.com