Is there an XQuery existence function?

Discussion in 'XML' started by Oliver Wong, Feb 13, 2007.

  1. Oliver Wong

    Oliver Wong Guest

    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
     
    Oliver Wong, Feb 13, 2007
    #1
    1. Advertising

  2. Oliver Wong wrote:
    > 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.


    --

    Martin Honnen
    http://JavaScript.FAQTs.com/
     
    Martin Honnen, Feb 13, 2007
    #2
    1. Advertising

  3. hi,

    Oliver Wong wrote:
    > 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 !
     
    Philippe Poulard, Feb 13, 2007
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Tamara
    Replies:
    3
    Views:
    352
    Jacob Yang [MSFT]
    Aug 12, 2003
  2. Ivan
    Replies:
    2
    Views:
    344
    Frank Schmitt
    Sep 4, 2003
  3. Replies:
    2
    Views:
    944
    Bengt Richter
    Aug 1, 2005
  4. Replies:
    0
    Views:
    818
  5. David Mathog

    Test for function existence?

    David Mathog, Mar 5, 2010, in forum: C Programming
    Replies:
    5
    Views:
    450
    Nobody
    Mar 5, 2010
Loading...

Share This Page