This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.
The current examples assume a value getter function which maps an item to exactly one atomic value. In practise, typical candidates for such a value getter more often than not may also produce the empty sequence, for example due to the rare but not impossible absence of some XML element or attribute. Please consider making the example a little more realistic by assuming a value getter function with this signature: function(item()) as xs:anyAtomicType? The implementation of eg:higest, for example, might then look like this: declare function eg:highest( $seq as item()*, $getValue as function(item()) as xs:anyAtomicType?) as item()* { fold-left( $seq, (), function($highestSoFar as item()*, $item as item()) as item()* { let $value := $getValue($item) let $highestValue := $highestSoFar[1] ! $getValue(.) return if (empty($value)) then $highestSoFar else if ($value > $highestValue or empty($highestSoFar)) then $item else if ($value = $highestValue) then ($highestSoFar, $item) else $highestSoFar } ) };
These functions are provided as examples. I'm reluctant to do work on them that is justified only because people might want to use them to solve a real problem that is different from the requirement they currently address. Indeed, one of the reasons that some of these functions were put in an appendix as examples of user-written functions, rather than putting them into the spec as core functions, was that we recognized there might be a variety of user requirements and it would be hard for a single function to satisfy them all.
The WG agreed with the reasoning in comment #1 and decided to take no action. There's plenty of scope for publishing useful example functions outside the W3C specification.