Laboratory 9 Querying XML documents with XPath and XQuery solution


It is expected that you do Homework 10 before implementation of the tasks
included in Laboratory 9.
This laboratory consists of 2 tasks.
Download and unzip a file scripts9.zip. Read and make yourself familiar
with the contents XML document included in file cataloge.xml downloaded
from the website.
Start SQL*Plus client on Windows system and connect to Oracle server running on the same system.
Execute the following scripts:
(1) xcreate.sql
(2) xload.sql with two parameters: the-full-path catalogue.xml.
Task 1 Querying XML documents with XPath
Implement and test the following queries in XPath query language.
(1) Find the names of all publishers.
(2) Find the values of all leaf level nodes describing authors.
(3) Find the values of all attributes.
(4) Find all character data in the document.
(5) Find all prices that have attribute currency.
(6) Find the titles of all books that have a name of publisher.
(7) Find the prices that have a value of attribute currency equal to AU$.
(8) Find the titles of all books whose author is James Bond.
(9) Find identifiers of all books described by a keyword .NET.
(10) Find the titles of all books that have no publisher.
You can use the scripts xcreate.sql, xload.sql, xlist.sql, xpath.sql, fxpath.sql to set up an environment and to compute XPath queries. Remember, that you must use SQL*Plus client installed on Windows system to execute the scripts !
When ready save XPath queries in the files task1-1.xp, task1-2.xp, task1- 3.xp, task1-4.xp, task1-5.xp, task1-6.xp, task1-7.xp, task1-8.xp, task1-9.xp, task1-10.xp.
The files task1-*.xp will be submitted at the end of laboratory class.
Task 2 Querying XML documents with XQuery
Read and make yourself familiar with the contents XML document included in file
cataloge.xml downloaded at the beginning of implementation of task 1.
Implement and test the following queries in XQuery query language.
(1) Find the titles and the prices of all books and order the results by ascending
titles.
(2) List the titles and publication dates of all books written by James Bond.
(3) Find the identifiers of all books indexed by a keyword Java.
(4) Find the identifiers of all books not indexed by a keyword Java.
(5) Find the titles and the authors of all books that have more than one author.
(6) Find the titles and publishers of all books published by a publisher of a book
entitled Maeve Ascendant.
(7) Find the titles and publishers of all books published by a publisher of a book
entitled Maeve Ascendant. Do not list a title Maeve Ascendant.
(8) Find the total number of authors for each book. List book title and the total
number of authors for each book.
(9) Find the total number of books published by each publisher. List a publisher
and the total number of books published.
(10)List the publishers that published more than one book.
You can use the scripts xcreate.sql, xload.sql, xlist.sql,
fxquery.sql to set up an environment and to compute XQuery queries.
Remember, that you must use SQL*Plus client installed on XP system to
execute the scripts !
When ready save XQuery queries in the files task2-1.xq, task2-2.xq, task2-3.xq, task2-4.xq, task2-5.xq, task2-6.xq, task2-7.xq, task2-8.xq, task2-9.xq, task2-10.xq.
The files task2-*.xq will be submitted at the end of laboratory class.
Submission
Zip the files task1-*.xp and task2-*.xq obtained as the solutions of Task 1
and Task 2 into a file solutions9.zip and submit the file through Moodle. A
submission procedure is the following.
(1) Connect to eLearning.
(2) Navigate to a folder SUBMISSIONS®LABORATORY SUBMISSIONS.
(3) Click at LABORATORY 9, Submit your solutions here link.
(4) Click at Add Attachments button.
(5) Navigate to a location where a file solutions9.zip has been saved.
(6) Select the file and click at Open button.
(7) Click at Submit button.
(8) Click at OK button to return to Home Page.
End of laboratory 9
Powered by