Skip to content

Custom inputs to XQuery or JavaScript modules

Mads Hansen edited this page Jul 28, 2017 · 6 revisions

It is possible to set custom input parameter values for modules that CORB executes.

Any property specified with prefix (with '.') INIT-MODULE, URIS-MODULE, PRE-BATCH-MODULE, PROCESS-MODULE, POST-BATCH-MODULE will be set as an external variable in the corresponding XQuery module (if that variable is defined as an external string variable in the XQuery module). For JavaScript modules the variables need be defined as global variables.

Custom input examples:

#Expects an external string variable maxLimit in URIS-MODULE XQuery or global variable for JavaScript.  
URIS-MODULE.maxLimit=1000
#Expects an external string variable startDate in PROCESS-MODULE XQuery or global variable for JavaScript.  
PROCESS-MODULE.startDate=2015-01-01

Alternatively, URIS-MODULE can pass custom inputs to PRE-BATCH-MODULE, PROCESS-MODULE, POST-BATCH-MODULE by returning one or more of the property values in above format before the count the of URIs.

Custom input from a URIS-MODULE example:

let $uris := cts:uris()
return ("PROCESS-MODULE.foo=bar", "POST-BATCH-MODULE.alpha=10", fn:count($uris), $uris)

If the URIS-MODULE needs the URIS_BATCH_REF property set as well, it needs to be just before the URIs count.

let $batchref-filename := sem:uuid-string() || ".csv"
let $uris := cts:uris()
return 
("PROCESS-MODULE.foo=bar","POST-BATCH-MODULE.alpha=10",$batchref-filename,fn:count($uris),$uris)