- From: Michael Dyck <MichaelDyck@home.com>
- Date: Fri, 09 Mar 2001 00:20:36 -0800
- To: www-xml-query-comments@w3.org
XML Query Use Cases W3C Working Draft 15 February 2001 Use Case R (I abbreviate "Expected Result" as "ER", and "Solution in XQuery" as "SiX".) ------------------ Query 2 (1.4.4.2): In the ER, the <item_tuple> for the Broken Bicycle has no <high_bid> element, but I don't see how the SiX manages to omit it. Supposedly, if $b is bound to an empty list, then <high_bid> max($b/bid) </high_bid> also yields an empty list, but to me this seems far-fetched. Instead, I'd expect it to either raise an error (from applying "max" to an empty list), or else yield <high_bid></high_bid> (although even that is a bit hard to justify). To achieve the ER, I think you need to replace <high_bid> max($b/bid) </high_bid> with IF empty($b) THEN [] ELSE <high_bid> max($b/bid) </high_bid> ------------------ Query 3 (1.4.4.3): The ER uses three element names: user_name user_rating item_description that do not occur in the input documents, but the SiX does not reproduce them. I think it needs to replace $u/name with <user_name> $u/name/text() </user_name> and similarly for the other two. ------------------ Query 5 (1.4.4.5) The ER has <auction_item> where the SiX has <jones_bike>. The ER has <high_bid> 55 </high_bid> where the SiX will generate <high_bid><bid> 55 </bid></high_bid> The ER has <bidder> Mary Doe </bidder> where the SiX will generate <high_bidder><name> Mary Doe </name></high_bidder> The ER includes an item for the Broken Bicycle, but the SiX does not generate it, because there are no appropriate bindings for $buyer and $highbid. I think all of these problems are fixed by the following SiX: <result> FOR $seller IN document("users.xml")//user_tuple, $item IN document("items.xml")//item_tuple WHERE $seller/name = "Tom Jones" AND $seller/userid = $item/offered_by AND contains($item/description, "Bicycle") RETURN <auction_item> $item/itemno , $item/description , FOR $buyer IN document("users.xml")//user_tuple, $highbid IN document("bids.xml")//bid_tuple WHERE $item/itemno = $highbid/itemno AND $highbid/userid = $buyer/userid AND $highbid/bid = max(document("bids.xml")//bid_tuple [itemno = $item/itemno]/bid) RETURN [ <high_bid> $highbid/bid/text() </high_bid> , <bidder> $buyer/name/text() </bidder> ] </auction_item> SORTBY (itemno) </result> ------------------ Query 6 (1.4.4.6): "For each item whose highest bid is more than twice its reserve price"... The SiX has WHERE $item/reserve_price < 2 * max($b/bid) which should be WHERE 2 * $item/reserve_price < max($b/bid) or more readably, WHERE max($b/bid) > 2 * $item/reserve_price -------------------- Query 18 (1.4.4.18): The ER has a single <bid_on_item> element for each distinct item that the user has bid on, but the SiX will generate multiple <bid_on_item> elements for the same item, one for each bid ($b) that the user has made on the item. One solution might be $i in distinct( ... ) -Michael Dyck
Received on Friday, 9 March 2001 03:24:33 UTC