Loading TOC...


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


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.

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


sem:if( fn:true(), "This is true", "This is not true")
This is true

Stack Overflow iconStack Overflow: Get the most useful answers to questions from the MarkLogic community, or ask your own question.