Dear BaseX people,
I have encountered a bug (?). Please consider this code:
= = = = = = = = =  begin = = =
declare namespace f="http://weatherreport.org/heavyweather";     declare 
function f:relatedNames($node, $relationship)  as xs:string* {    let $fnName 
:=         function($node) {            let $_DEBUG := trace(count($node), 
'#node: ')             return name($node)}        let $items :=        
switch($relationship)        case 'child' return $node/*        default return 
error()    return        $items/$fnName(.) => distinct-values() => sort() => 
string-join(', ')};   
let $doc := <doc><a/><b/><c/></doc>return f:relatedNames($doc, 'child')  
= = = = = = = = =  end = = =

= = = = = = = = =  output = = =#node: 3Stopped at 
C:/projects/foxpath-examples/pre-balisage/problem-basex2.xq, 15/25:[XPTY0004] 
Item expected, sequence found: (<a/>, <b/>, <c/>).= = = = = = = = = = = = = = = 
=

The call $fnName(.) receives a single item, but three items arrive at the 
function item!
With kind regards,Hans-Jürgen
PS: The funny switch() seems to play a part in the game, when I removed it, the 
issue vanished.PPS: BaseX 11.8 [Standalone]

Reply via email to