Ask Question

Using the XML Document below (library with books), define the following queries in XQuery: (a) Give the titles of all Books sorted by Price. (b) How many books were written by Abiteboul? (c) Give for each author, the number of books he has written.

+3
Answers (1)
  1. 11 December, 07:17
    0
    a) use order by clause for sorting

    for $x in doc ("books. xml") / bib/book order by xs:float ($x/price) return $x/title (default sorted in ascending order)

    or

    for $x in doc ("books. xml") / bib/book order by xs:float ($b/price) descending return $b/title (sorted in descending order)

    b) doc ("books. xml") / /book[author = 'Abiteboul']

    c) for $x in distinct-values (doc ("bib. xml") / bib/book/author)

    return

    {$x}

    {count (doc ("bib. xml") / /book[exists (indexof (author,$x)) ]) }
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “Using the XML Document below (library with books), define the following queries in XQuery: (a) Give the titles of all Books sorted by ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers