[xquery-talk] What do people do about warnings?

John Snelson john.snelson at oracle.com
Fri Jan 12 10:39:36 PST 2007


Any other way to do this would involve using implementation specific 
constructs.

I'm surprised that you find it necessary to try to fool the query 
optimiser into not getting rid of your trace() function call. I would 
consider it a bug if it was optimised out of your query - certainly the 
XQuery implementations I work on would not do that.

John

James A. Robinson wrote:
> 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)
>   as schema-element(foo:bar)
>   {
>     if (doc-unavailable($uri))
>     then (
>        rp:_message($uri, 'resolve:externalize: uri unavailable')
>     )
>     else (
>       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)
>     return (
>      if ($w) then () else ()
>     )
>   };
> 
> Are there better techniques someone could suggest?
> 
> Jim
> 
> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
> James A. Robinson                       jim.robinson at stanford.edu
> Stanford University HighWire Press      http://highwire.stanford.edu/
> +1 650 7237294 (Work)                   +1 650 7259335 (Fax)
> _______________________________________________
> talk at x-query.com
> http://x-query.com/mailman/listinfo/talk



More information about the talk mailing list