Is there an XQuery existence function?

O

Oliver Wong

Is there a function (or other construct) which will return true if a certain
XPath points to an existing element, and false otherwise? E.g.

exists(./foo/bar)

would return true if there exists a foo/bar element which is the child of
the current context node, and false otherwise.

- Oliver
 
M

Martin Honnen

Oliver said:
Is there a function (or other construct) which will return true if a certain
XPath points to an existing element, and false otherwise? E.g.

exists(./foo/bar)

would return true if there exists a foo/bar element which is the child of
the current context node, and false otherwise.

If you use a path yielding a node set respectively node sequence in a
boolean context then the result is true if there is at least one node in
the sequence and false otherwise meaning you can simply do e.g.
<xsl:if test="./foo/bar">
in XSLT or e.g.
if (./foo/bar) then
in XQuery.
 
P

Philippe Poulard

hi,

Oliver said:
Is there a function (or other construct) which will return true if a certain
XPath points to an existing element, and false otherwise? E.g.

exists(./foo/bar)

try this :
boolean(foo/bar)
would return true if there exists a foo/bar element which is the child of
the current context node, and false otherwise.

- Oliver

--
Cordialement,

///
(. .)
--------ooO--(_)--Ooo--------
| Philippe Poulard |
-----------------------------
http://reflex.gforge.inria.fr/
Have the RefleX !
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top