Dear fellow users,
I updated to BaseX 9.1 and I observe an unexpected behaviour of fn:trace http://docs.basex.org/wiki/XQuery_3.1#fn:trace
I inserted logging statements to give warnings in case important content is missing, like so:
declare function local:my-function ( $id as xs:string?, $value as xs:string? ) as xs:string? { if ( $ value != '' ) then "foo" else trace( $id, 'No foo given for this record! ') } ;
So far, the fn:trace output could be read in the Info window of BaseX. Now, the id-value of the above call to trace is ALSO output to the Result window.
Even though the documentation states that the behaviour of trace is implementation-dependent, this behaviour seems unexpected and unhelpful. The extra output to result is hard to notice and destroys a possibly fully valid result file (the trace call is only a warning, there is not necessarily an actual error).
1. Is there anything wrong with my XQuery?
2. Why is trace behaving this way in BaseX 9.1?
3. How to best achieve the desired output? (Desired output is: result file unchanged and warning in Info window.)
Thank you and best regards, MK
This is indeed the correct behavior of fn:trace: The first argument will always be returned to the user [1]. If you want to swallow the supplied argument, you can use [2].
Do you remember which version of BaseX did not pass on the input?
All the best, Christian
[1] https://www.w3.org/TR/xpath-functions-31/#func-trace [2] http://docs.basex.org/wiki/Profiling_Module#prof:dump
On Mon, Nov 12, 2018 at 10:26 AM Kittelmann, Maike kittelmann@sub.uni-goettingen.de wrote:
Dear fellow users,
I updated to BaseX 9.1 and I observe an unexpected behaviour of fn:trace
http://docs.basex.org/wiki/XQuery_3.1#fn:trace
I inserted logging statements to give warnings in case important content is missing, like so:
declare function local:my-function ( $id as xs:string?,
$value as xs:string? )
as xs:string?
{
if ( $ value != '' )
then
“foo”
else
trace( $id, 'No foo given for this record! ')
} ;
So far, the fn:trace output could be read in the Info window of BaseX.
Now, the id-value of the above call to trace is ALSO output to the Result window.
Even though the documentation states that the behaviour of trace is implementation-dependent, this behaviour seems unexpected and unhelpful. The extra output to result is hard to notice and destroys a possibly fully valid result file (the trace call is only a warning, there is not necessarily an actual error).
Is there anything wrong with my XQuery?
Why is trace behaving this way in BaseX 9.1?
How to best achieve the desired output? (Desired output is: result file unchanged and warning in Info window.)
Thank you and best regards,
MK
basex-talk@mailman.uni-konstanz.de