Name

boolean( ) — converts another datatype into a boolean

Synopsis

Defined in: XPath 1.0
Parameters: object bool (optional)
Return type: boolean

Other datatypes are converted according to the following rules:

node-set

An empty node-set produces false; anything else produces true.

number

Zero and NaN produce false; anything else produces true.

string

An empty string produces false; anything else produces true.

When called with no parameters, the converted value of the context node is returned.

This example returns true if the Location Path a/b happens to select one or more nodes; otherwise, it returns false:

boolean(a/b)

Get XForms Essentials now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.