The schema-valid() function

Smartsite 7.2 - ...

The schema-valid() function returns a boolean indicating whether or not the specified node is valid, taking only the schema validity into account (whether or not the node's value conforms to the schema type that applies for the node, if any).

XML CopyCode image Copy Code
string exf:schema-valid(node)

This extension function is particularly useful when you want to supply different alert messages to the user, dependent on the reason why a field is not valid (wrong input, no input when the field is required, duplicate entry, etc.)

Example:

XML CopyCode image Copy Code
<xf:bind nodeset="instance('res')/code_invalid" 
      relevant="string-length(instance()/cms:entry/cms:code) &gt; 0 and not(exf:schema-valid(instance()/cms:entry/cms:code))" />

Within the above example, the code_invalid node within the 'res' instance (which contains an alert message that the specified code is not valid according to schema restrictions) is set to relevant when the code field within the default instance is not empty and (also) does not comply with the schema restrictions.

Namespaces

This function is available within the Smartsite XForms namespace (http://smartsite.nl/namespaces/xforms/1.0).