Returns true if the supplied node has one or more child nodes (of any kind).
If the argument is omitted, it defaults to the context item (
behavior of the function if the argument is omitted is exactly the same as if the
context item had been passed as the argument.
Provided that the supplied argument
$node matches the expected type
node()?, the result of the function call
fn:has-children($node) is defined to be the same as the result of the
The following errors may be raised when
$node is omitted:
If the context item is absent, dynamic error
If the context item is not a node, type error .
$node is an empty sequence the result is false.
The motivation for this function is to support streamed evaluation. According to the streaming rules in , the following construct is not streamable:
This is because it makes two downward selections to read the child
elements. The use of
fn:has-children in the
is intended to circumvent this restriction.
Although the function was introduced to support streaming use cases, it has general utility as a convenience function.