Talk:XQuery/Checking for Required Parameters

Dan, I've implemented your code but made a few changes:

- aligned the XQuery variable names with the parameter names - not necessary but the messages should refer to the external parameter name, not the internal name - cut out some unnecessary parentheses

Here's the code as stored xquery version "1.0"; declare namespace request="http://exist-db.org/xquery/request";

let $parameter-p1 := request:get-parameter('p1', '')

return if (not($p1)) then Parameter p1 is missing. Parameter p1 is a required parameter for this XQuery. else Parameter p1={$parameter-p1} No parameter p1=yes

and xquery version "1.0"; declare namespace request="http://exist-db.org/xquery/request";

let $parameter-p1 := request:get-parameter('p1', '') let $parameter-p2 := request:get-parameter('p2', '')

return if (not($p1) or not($p2)) then Parameter p1 or p2 is missing. Both arguments required for this XQuery. Parameter p1={$parameter-p1} Parameter p2={$parameter-p2} else Parameter p1={$parameter-p1} Parameter p2={$parameter-p2} No parameters p1=yes p1=yes and p2=no