{-- String literal --} "Hello World !" {-- Integer literal --} "-123"
{-- Returns the document node representing the document named "R-items.xml" in collection named "data". The document() function is one of the XQuery 1.0 built-in functions --} document("data/R-items.xml")
{-- Returns all the "item_tuple" elements in the document "data/R-items.xml" that had a reserve price over 50 dollars --} document("data/R-items.xml")/items/item_tuple[reserve_price > 50]
{-- For each "item_tuple" element return the description and reserve_price if the reserve_price is below 50 dollars, and return them in alphabetically ascending order of description --} for $item in document("data/R-items.xml")/items/item_tuple where $item/reserve_price > 50 order by $item/description return <item>{$item/description, $item/reserve_price}</item>
{-- Tell me if the average of the reserve_price values is less than 200 dollars. This expression evaluates to a xs:string typed value --} if(avg(document("data/R-items.xml")//reserve_price) < 200) then "Average reserve_price is less than 200 dollars" else "Average reserve_price is not less than 200 dollars"
{-- Quantified expressions return a boolean value based on applying a test to a sequence of tuples. There are two types of quantifiers: -> Existential Quantifiers (some) -> Universal Quantifiers (every) Here are examples of these two types of quantifiers --}
{-- Tell me if there exists at least one reserve_price that is greater than 1000 dollars. Return value if true if atleast one reserve_price has value greater than 1000 --} some $price in document("data/R-items.xml")//reserve_price satisfies $price > 1000
{-- Tell me if all reserve_price values are less than 100000 --} every $price in document("data/R-items.xml")//reserve_price satisfies $price < 100000
{-- define a function that takes a bid_tuple element and tells me whether the bidder is a valid user (has an entry in the R-users.xml document. The format of the "bid_tuple" element is as indicated in the R-bids.xml document --} define function verifyUser($bid_tuple as element) as xs:boolean { some $user in document("data/R-users.xml")//userid satisfies $user =$bid_tuple/userid }