Ask Question
25 October, 14:55

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.

+5
Answers (1)
  1. 25 October, 17:19
    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 and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers