(Q1) In the second chapter of the document named "zoo.xml", find the figure(s) with caption "Tree Frogs". doc("zoo.xml")//chapter[2]//figure[caption = "Tree Frogs"] (Q2) Find captions of figures that are referenced by elements in the chapter of "zoo.xml" with title "Frogs". doc("zoo.xml")//chapter[title = "Frogs"] //figref/@refid=>fig/caption (Q3) List the names of the second-level managers of all employees whose rating is "Poor". //emp[rating = "Poor"]/@mgr=>emp/@mgr=>emp/name (Q4) List the titles of books published by Morgan Kaufmann in 1998. FOR $b IN doc("bib.xml")//book WHERE $b/publisher = "Morgan Kaufmann" AND $b/year = "1998" RETURN {$b/title} (Q5) List each publisher and the average price of its books. FOR $p IN distinct(doc("bib.xml")//publisher) LET $a := avg(doc("bib.xml")//book[publisher = $p]/price) RETURN {$p/text()} {$a} (Q6) List the publishers who have published more than 100 books. { FOR $p IN distinct(doc("bib.xml")//publisher) LET $b := doc("bib.xml")//book[publisher = $p] WHERE count($b) > 100 RETURN {$p} } (Q7) Invert the structure of the input document so that, instead of each book element containing a sequence of authors, each distinct author element contains a sequence of book-titles. { FOR $a IN distinct(doc("bib.xml")//author) RETURN {$a/text()} { FOR $b IN doc("bib.xml")//book[author = $a] RETURN $b/title } } (Q8)List all books with price greater than $100, in order by first author; within each group of books with the same first author, list the books in order by title. FOR $b IN doc("bib.xml")//book[price > 100] ORDER BY $b/author[1], $b/title RETURN {$b} (Q9) Find titles of books in which sailing is mentioned in every paragraph. FOR $b IN //book WHERE EVERY $p IN $b//para SATISFIES contains($p, "sailing") RETURN {$b/title} =============================================================== Interval inclusion model for node numbering is important for cheap determination of ancestor-descendant relationships.