The valid() function

Release 2.0 - ...

The valid() extension function can be used to determine if a (bound) instance data node or a subtree of nodes, and optionally its (bound) descendant nodes, are valid.

  CopyCode image Copy Code
boolean sxf:valid(node-set expression, recursive, relevant)

A node is considered valid if it conforms to its schematype (if any), its constraint (if any) is satisfied and, when the node is required, its value is non-empty.
If any of the nodes is not valid, this function returns false(). If all nodes are valid, this function returns true().

Parameters:

  • node-set expression: Optional XPath expression specifying which nodes to evaluate.
  • recursive: Optional boolean expression to indicate whether or not recursion should be applied. Defaults to false().
  • relevant: Optional boolean expression to indicate whether or not non-relevant nodes should be excluded. Defaults to false(), which means non-relevant nodes are also taken into account.

If the first argument is omitted, the current evaluation context is used.

Examples:

  CopyCode image Copy Code
sxf:valid(Number)
sxf:valid(Number | Phone)
sxf:valid(Address, true())
sxf:valid(Address, true(), true())

The first expression tests whether or not the Number node is valid.
The second expression tests whether or not the Number node and the Phone node are valid.
The third expression tests whether or not the Address node and all of its descendants are valid.
TheĀ fourth expression tests whether or not the Address node and all of its descendants are valid, skipping non-relevant nodes.


Namespace

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

(This function is much like the xxforms:valid function from Orbeon.)