Ask Question
8 October, 04:39

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.

+2
Answers (1)
  1. 8 October, 05:22
    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?
Get 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 there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers