|
[XQuery Talk Mailing List Archive Home] [By Date] [By Thread] [By Subject] [By Author] [Recent Entries] [Reply To This Message] What do people do about warnings?James A. Robinson jim.robinson at stanford.eduThu 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) 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 http://x-query.com/mailman/listinfo/talk Stanford University HighWire Press http://highwire.stanford.edu/ +1 650 7237294 (Work) +1 650 7259335 (Fax)
|
Purchase Stylus Studio Online Today!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|






