MarkLogic Server 11.0 Product Documentation
sem:if

sem:if(
   $condition as xs:boolean,
   $then as item()*,
   $else as item()*
) as item()*

Summary

The IF function form evaluates the first argument, interprets it as a effective boolean value, then returns the value of expression2 if the EBV is true, otherwise it returns the value of expression3. Only one of expression2 and expression3 is evaluated. If evaluating the first argument raises an error, then an error is raised for the evaluation of the IF expression. This XQuery function backs up the SPARQL IF() functional form.

This function is a built-in.

Parameters
condition The condition.
then The then expression.
else The else expression.

Example

sem:if( fn:true(), "This is true", "This is not true")
=>
This is true
Powered by MarkLogic Server | Terms of Use | Privacy Policy