XQuery : Some .... in .... satisfies

Discussion in 'XML' started by Istvan, Sep 4, 2006.

  1. Istvan

    Istvan Guest

    Hello

    Have anybody an idea how to solve "Some ... in ... satisfies " with
    standard functions ?


    For example this:
    "List the reserves of those open auctions where a
    certain person issued a bid before another person."


    let $auction := doc("auction.xml") return
    for $b in $auction/site/open_auctions/open_auction
    where
    some $pr1 in $b/bidder/personref[@person = "person20"],
    $pr2 in $b/bidder/personref[@person = "person51"]
    satisfies $pr1 << $pr2
    return <history>{$b/reserve/text()}</history>


    Thats an query of the XMark Benchmark... Q4.
    I need it to execute on Tamino, and so I have to rewrite it, because
    Tamino doesn't support
    "Some ... in .... satisfies".
     
    Istvan, Sep 4, 2006
    #1
    1. Advertising

  2. Been a while since I've worked with XQuery, but in XSLT I'd rephrase
    that as "find all which satisfy; is that nodeset empty". In XSLT any
    comparison expression on nodesets is taken as "does any element
    satisfy"; I'd expect that to be true of XQuery too since the underlying
    semantics are similar.

    --
    Joe Kesselman / Beware the fury of a patient man. -- John Dryden
     
    Joseph Kesselman, Sep 5, 2006
    #2
    1. Advertising

  3. Hi,

    "Some..in..satisfies" _is_ standard XQuery and has been for a long time;
    I'm not sure why Tamino wouldn't support it.

    But anyway, how about something like (untested):

    let $auction := doc("auction.xml") return
    for $b in $auction/site/open_auctions/open_auction
    where
    (for $pr1 in $b/bidder/personref[@person = "person20"]
    return
    $b/bidder/personref[@person = "person51"][. >> $pr1])
    return <history>{$b/reserve/text()}</history>

    Hope that helps,
    Priscilla
    ---------------------------------------------
    Priscilla Walmsley
    Author, XQuery (Coming in 2006 from O'Reilly)
    http://www.datypic.com
    http://www.xqueryfunctions.com
    ---------------------------------------------

    *** Sent via Developersdex http://www.developersdex.com ***
     
    Priscilla Walmsley, Sep 10, 2006
    #3
  4. Istvan

    Istvan Guest

    problem solved.



    Tamino Developers said:


    let $auction := doc("auction.xml") return
    for $b in $auction/site/open_auctions/open_auction
    where
    some $pr1 in $b/bidder/personref[@person = "person20"],
    $pr2 in $b/bidder/personref[@person = "person51"]
    satisfies $pr1 << $pr2
    return <history>{$b/reserve/text()}</history>
     
    Istvan, Sep 10, 2006
    #4
  5. Istvan

    Istvan Guest

    problem solved.



    Tamino Developers said:

    let $auction := input()/auction
    for $b in $auction/site/open_auctions/open_auction
    for $pr1 in $b/bidder/personref[@person = "person20"],
    $pr2 in $b/bidder/personref[@person = "person51"]
    where $pr1 << $pr2 return $b/reserve/text()
     
    Istvan, Sep 10, 2006
    #5
  6. Hi,

    I don't think this is the same thing because you are going to get
    duplicate results for the same auction if there is more than one bid
    that satisfies the condition.

    Priscilla

    ----------------------------------
    Priscilla Walmsley
    Author, Definitive XML Schema
    Definitive XQuery
    http://www.datypic.com
    ----------------------------------

    *** Sent via Developersdex http://www.developersdex.com ***
     
    Priscilla Walmsley, Sep 10, 2006
    #6
  7. Istvan

    Istvan Guest

    Priscilla Walmsley wrote:
    > Hi,
    >
    > I don't think this is the same thing because you are going to get
    > duplicate results for the same auction if there is more than one bid
    > that satisfies the condition.



    Hi !

    I wanted to test both. But the query doesn't give a result on the XMark
    generated data.
    I don't know why is this query in the XMark Tests included....

    But I think you are right


    Thank you Priscilla !

    You are super *g*
     
    Istvan, Sep 10, 2006
    #7
    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. HNguyen
    Replies:
    0
    Views:
    1,177
    HNguyen
    Jun 3, 2004
  2. Ant...
    Replies:
    6
    Views:
    383
    Ant...
    Oct 28, 2003
  3. Istvan

    Some .... in .... satisfies

    Istvan, Sep 4, 2006, in forum: XML
    Replies:
    0
    Views:
    340
    Istvan
    Sep 4, 2006
  4. CK
    Replies:
    1
    Views:
    464
  5. Bob Sanders
    Replies:
    4
    Views:
    149
    Robert Dober
    Dec 1, 2008
Loading...

Share This Page