Loading TOC...

sem.if

sem.if(
   $condition as Boolean,
   $then as Sequence,
   $else as Sequence
) as Sequence

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( 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.

Comments

The commenting feature on this page is enabled by a third party. Comments posted to this page are publicly visible.