<?xml version="1.0" encoding="UTF-8"?><api:function-page xml:base="/apidoc/8.0/sem.if.xml" generated="2015-10-07T16:36:00.016766-07:00" mode="javascript" xmlns:api="http://marklogic.com/rundmc/api"><api:function-name>sem.if</api:function-name><api:suggest>sem.if</api:suggest><api:suggest>sem</api:suggest><api:function-link mode="xquery" fullname="sem:if">/apidoc/8.0/sem:if.xml</api:function-link><api:function mode="javascript" name="if" type="builtin" lib="sem" category="Semantics" hidden="false" bucket="MarkLogic Built-In Functions" prefix="sem" namespace="http://marklogic.com/semantics" fullname="sem.if"><api: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.
  <p xmlns="http://www.w3.org/1999/xhtml">This function is a built-in.</p>
</api:summary><api:params><api:param name="condition" type="xs:boolean"><api:param-description>
    The condition.
  </api:param-description><api:param-name>condition</api:param-name><api:param-type>Boolean</api:param-type></api:param><api:param name="then" type="item()*"><api:param-description>
    The then expression.
  </api:param-description><api:param-name>then</api:param-name><api:param-type>ValueIterator</api:param-type></api:param><api:param name="else" type="item()*"><api:param-description>
    The else expression.
  </api:param-description><api:param-name>else</api:param-name><api:param-type>ValueIterator</api:param-type></api:param></api:params><api:return>ValueIterator</api:return><api:example class="javascript"><pre xml:space="preserve" xmlns="http://www.w3.org/1999/xhtml">
sem.if( true, "This is true", "This is not true");
=&gt;
This is true
</pre></api:example></api:function></api:function-page>