This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 29626 - fn:fold-left in appendix - calls not correct
Summary: fn:fold-left in appendix - calls not correct
Status: CLOSED DUPLICATE of bug 28885
Alias: None
Product: XPath / XQuery / XSLT
Classification: Unclassified
Component: Functions and Operators 3.1 (show other bugs)
Version: Candidate Recommendation
Hardware: PC Windows NT
: P2 normal
Target Milestone: ---
Assignee: Michael Kay
QA Contact: Mailing list for public feedback on specs from XSL and XML Query WGs
Depends on:
Reported: 2016-05-15 18:02 UTC by Hans-Juergen Rennau
Modified: 2016-07-21 14:14 UTC (History)
0 users

See Also:


Description Hans-Juergen Rennau 2016-05-15 18:02:10 UTC
In the appendix, examples use incorrect invocations of fn:fold-left - the order of arguments is ($f, $zero, $seq) - whereas it should be ($seq, $zero, $f). 

This concerns the following examples (XSLT and XQuery):
* eg:distinct-nodes-stable
* eg:higheest
* eg:lowest


declare function eg:highest(
                     $f as function(item()) as xs:anyAtomicType, 
                     $seq as item()*)
                  as item()* {
       function($highestSoFar as item()*, $this as item()*) as item()* {
         let $thisValue := $f($this)
         let $highestValue := $f($highestSoFar[1])
           if ($thisValue gt $highestValue)
             then $this
           else if ($thisValue eq $highestValue)
             then ($highestSoFar, $this)
           else $highestSoFar
       }, fn:head($seq), fn:tail($seq))
Comment 1 Hans-Juergen Rennau 2016-05-15 18:20:30 UTC
There is a second bug hidden in the examples eg:highest and eg:lowest:
the inline function expression passed to fn:fold-left is

   function($highestSoFar as item()*, $this as item()*) as item()* {...}

Note the second parameter:
   $this as item()*

which is incorrect - it should be
   $this as item()

(no occurrence indicator).
Comment 2 Michael Kay 2016-05-23 11:48:27 UTC
Thanks for reporting it. The problem was fixed as part of the resolution of bug #28885.

*** This bug has been marked as a duplicate of bug 28885 ***