Tests if the result of a query is empty.
An XQuery or XPath expression.
The input that the query processes. The value can be an XML STRING
or a STRUCT
of variable values:
STRING
: The string is bound to the initial context item of the query as XML.
STRUCT
: A STRUCT
with an even number of fields. Each pair of fields defines a variable binding (name, value) for the query. The name fields must be type STRING
, and the value fields can be any supported primitive. See "About Data Type Conversions."
true
if the result of the query is not empty, and false
otherwise.
false
if the query raises a dynamic error.
This example parses and binds the input XML string to the initial context item of the query "x/y":
> SELECT xml_exists("x/y", "<x><y>123</y></x>") FROM src LIMIT 1;
true
This example defines two query variables, $data
and $value
.
> SELECT xml_exists( "parse-xml($data)/x/y[@id = $value]", struct( "data", "<x><y id='1'/><y id='2'/></x>", "value", 2 ) ) FROM src LIMIT 1; true
In this example, an error is written to the log, because the input XML is invalid.
> SELECT xml_exists("x/y", "<x><y>123</invalid></x>") FROM src LIMIT 1;
false