Hi Tim, I would rather use exception handling for something like that. Make the test function 'assert', and have it call 'error(...)' when conditions aren't met. Use try catch to handle the exception more gracefully..
Kind regards, Geert -----Oorspronkelijk bericht----- Van: [email protected] [mailto:[email protected]] Namens Tim Meagher Verzonden: donderdag 15 september 2011 16:22 Aan: 'General MarkLogic Developer Discussion' Onderwerp: Re: [MarkLogic Dev General] How to effectively pass variables by reference to an xquery function? For example, in the following module (which demonstrates at least one approach to the problem) I set the global error variable to true() if a certain condition is met: xquery version "1.0-ml"; declare namespace t = "test"; declare variable $t:error := false(); declare function t:test($val) {( if ($val eq "b") then xdmp:set($t:error, true()) else (), $val )}; let $val1 := t:test("a") let $val2 := t:test("b") let $val3 := t:test("c") return ( $val1, ", ", $val3, ", ", $val2, ", ", if ($t:error) then "oops" else "okay" ) -----Original Message----- From: [email protected] [mailto:[email protected]] On Behalf Of Geert Josten Sent: Thursday, September 15, 2011 10:03 AM To: General MarkLogic Developer Discussion Subject: Re: [MarkLogic Dev General] How to effectively pass variables by reference to an xquery function? Hi Tim, Can you elaborate a bit more on the use case? Kind regards, Geert _______________________________________________ General mailing list [email protected] http://developer.marklogic.com/mailman/listinfo/general _______________________________________________ General mailing list [email protected] http://developer.marklogic.com/mailman/listinfo/general
