boolean-from-stringAdded by IBM on August 8, 2013 | Version 1 (Original)
Converts a string to a Boolean value. This is useful for converting string content, such as content from an instance data node, to a Boolean result, which is required to set some of the properties on data elements, such as relevant and read-only.
Table 1. boolean-from-string parameters
|string||string||the string to convert. The strings "true" and "1" are converted to true. All other strings are converted to false.|
A Boolean value.
The following data model contains two instances. The first instance, called "po", contains the beginning of a table that will track the items that are being ordered. The second instance, called "temps", contains a temporary variable that tracks whether the form is being submitted.
The following bind determines whether each row in the table is relevant:
<xforms:instance id="po" xmlns="">
<xforms:instance id="temps" xmlns="">
This bind uses an if, instance, and boolean-from-string function to create following logic: if the row has a quantity greater than zero, or the form is not being submitted (as tracked by the submitting element in the temps instance), then return "true"; otherwise, return "false". Since the if function returns these values as strings, the boolean-from-string function is used to convert the result to a Boolean value, which then sets the relevance of the nodeset.
relevant="boolean-from-string( if( qty > 0 or
instance('temps')/submitting='false', 'true', 'false'))"/>