<?xml version="1.0" encoding="UTF-8"?><api:function-page xml:base="/apidoc/8.0/fn.boolean.xml" generated="2015-10-07T16:36:00.016766-07:00" mode="javascript" xmlns:api="http://marklogic.com/rundmc/api"><api:function-name>fn.boolean</api:function-name><api:suggest>fn.boolean</api:suggest><api:suggest>fn</api:suggest><api:suggest>boolean</api:suggest><api:function-link mode="xquery" fullname="fn:boolean">/apidoc/8.0/fn:boolean.xml</api:function-link><api:function mode="javascript" name="boolean" type="builtin" lib="fn" category="SequenceBuiltins" bucket="W3C-Standard Functions" hidden="false" prefix="fn" namespace="http://www.w3.org/2005/xpath-functions" fullname="fn.boolean"><api:summary>
<p xmlns="http://www.w3.org/1999/xhtml">
Computes the effective boolean value of the sequence $arg. See Section 2.4.3
Effective Boolean Value[XP].
</p>
<p xmlns="http://www.w3.org/1999/xhtml">NOTE: NEW 1.0 SEMANTICS NOT IMPLEMENTED: STILL USES MAY 2003 SEMANTICS.</p>
<p xmlns="http://www.w3.org/1999/xhtml">
If $arg is the empty sequence, fn:boolean returns false.
</p><p xmlns="http://www.w3.org/1999/xhtml">
If $arg is a sequence whose first item is a node, fn:boolean returns true.
</p><p xmlns="http://www.w3.org/1999/xhtml">
If $arg is a singleton value of type xs:boolean or a derived from xs:boolean,
fn:boolean returns $arg.
</p><p xmlns="http://www.w3.org/1999/xhtml">
If $arg is a singleton value of type xs:string or a type derived from xs:string
or xs:untypedAtomic, fn:boolean returns false if the operand value has zero
length; otherwise it returns true.
</p><p xmlns="http://www.w3.org/1999/xhtml">
If $arg is a singleton value of any numeric type or a type derived from a
numeric type, fn:boolean returns false if the operand value is NaN or is
numerically equal to zero; otherwise it returns true.
</p><p xmlns="http://www.w3.org/1999/xhtml">
In all other cases, fn:boolean raises a type error [err:FORG0006] when 
run in XQuery strict mode (1.0).
</p><p xmlns="http://www.w3.org/1999/xhtml">
The static semantics of this function are described in
<a href="http://www.w3.org/TR/xquery-semantics/#sec_fn_boolean">Section
7.2.4 The fn:boolean function[FS]</a>.
</p><p xmlns="http://www.w3.org/1999/xhtml">
Note:
</p><p xmlns="http://www.w3.org/1999/xhtml">
The result of this function is not necessarily the same as " $arg cast as
xs:boolean ". For example, fn:boolean("false") returns the value "true" whereas
"false" cast as xs:boolean returns false.
</p>
</api:summary><api:params><api:param name="arg" type="ValueIterator | Array" class="javascript"><api:param-description>
  A sequence of items (as a ValueIterator or as an Array, where the sequence
  is defined as each item of the array).   
  </api:param-description><api:param-name>arg</api:param-name><api:param-type>ValueIterator | Array</api:param-type></api:param><api:param name="collation" type="xs:string" optional="true"><api:param-description>
  The optional name of a valid collation URI.  For information on the
  collation URI syntax, see the <em xmlns="http://www.w3.org/1999/xhtml">Search Developer's Guide</em>.
  </api:param-description><api:param-name>collation</api:param-name><api:param-type>String</api:param-type></api:param></api:params><api:return>Boolean</api:return><api:example class="javascript"><pre xml:space="preserve" xmlns="http://www.w3.org/1999/xhtml">
var x = ["a", "b", "c"];
fn.boolean(x);
=&gt; true

var x = ["a", "b", "c"];
fn.boolean(x[0]);
=&gt; true

var x = ["a", "b", "c"];
fn.boolean(x[4]);
=&gt;  false
</pre>
</api:example></api:function></api:function-page>