Name

if( ) — evaluates an expression, returning two possible strings depending on the result

Synopsis

Defined in: XForms 1.0
Parameters: boolean test (required); string trueval (required); string falseval (required)
Return type: string

This function evaluates the boolean test parameter, and returns trueval if the test is true, or falseval otherwise. Note that all three parameters are always evaluated—no “short circuit” evaluation takes place.

If the evaluation of a/b yields true, this example returns “it worked”, and otherwise returns “it failed”:

if(boolean-from-string(a/b), "it worked", "it failed")

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.