A little note:

  let $_DEBUG := trace(count($node), '#node: ')
  return name($node)}

With XQuery 4, you can use fn:message to avoid unused variables (the
official successor of prof:dump) [1]:

  message(count($node), '#node: '),
  name($node)}

[1] https://docs.basex.org/12/Standard_Functions#fn:message




On Wed, Apr 9, 2025 at 11:18 PM Hans-Juergen Rennau <[email protected]>
wrote:

> Simply phantastic! Simply ... BaseX!
>
> Thank you, greetings -
> Hans-Jürgen
>
> Am Mittwoch, 9. April 2025 um 21:44:11 MESZ hat Christian Grün <
> [email protected]> Folgendes geschrieben:
>
>
> Hi Hans-Jürgen,
>
> Thanks for the observation. A simplified version of your query is:
>
> let $a := 'x'
> let $b := if($a) then (<a/>, <b/>) else error()
> return $b/name()
>
> The problem has been fixed in the latest snapshot [1].
>
> Best,
> Christian
>
> [1] https://files.basex.org/releases/latest/
>
>
> On Wed, Apr 9, 2025 at 8:29 PM Hans-Juergen Rennau <[email protected]>
> wrote:
>
> 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: 3
> Stopped 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