[xquery-talk] What do people do about warnings?
James A. Robinson
jim.robinson at stanford.edu
Thu Jan 11 10:32:32 PST 2007
If one is writing a library where a condition is encountered which
is not error but which is 'unexpected', I want to log a message
and proceed. Is fn:trace the best technique for this? Right now
this is what I came up with:
Some code executing in a 'public' library' might be like:
declare function resolve:externalize($uri as xs:anyURI)
rp:_message($uri, 'resolve:externalize: uri unavailable')
let $doc := doc($uri)
and in a private library:
: Private function to emit a messages. It uses fn:trace to
: throw a message in an implementation defined method and
: returns the empty sequence.
: @param $node a node() to display as part of the message.
: @param the message to emit.
: @return the empty sequence.
declare function rp:_message($node, $message as xs:string)
(: Use $w to try and prevent optimizer from throwing this call away. :)
let $w := trace($node, $message)
if ($w) then () else ()
Are there better techniques someone could suggest?
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
James A. Robinson jim.robinson at stanford.edu
Stanford University HighWire Press http://highwire.stanford.edu/
+1 650 7237294 (Work) +1 650 7259335 (Fax)
More information about the talk