从XQuery程序中,我想记录当前函数的名称。有没有一种方法可以在不引发异常的情况下获取当前函数的名称?
我可以通过引发异常并记录堆栈帧信息来获取功能信息。但是有没有一种方法可以获取当前的函数名称而又不会抛出这样的异常
xquery version "1.0-ml";
declare function local:logStuff( $str as xs:string )
{
try { fn:error() }
catch( $ex ) {
let $frame := ($ex/error:stack/error:frame)[2]
let $function as xs:string := $frame/error:operation
let $line as xs:numeric := $frame/error:line
let $column as xs:numeric := $frame/error:column
return
fn:concat(
"message: '", $str, "' In Function: ", $function,
" line: ", $line, " column: ", $column
)
}
};
declare function local:callingFunction()
{
local:logStuff( "I want to log this line of code with function info.")
};
local:callingFunction()
,
"And continue with the program ..."