Computer Science 4411a/9538a

Assignment 2

Due: Mar. 12, 2012

 

Please use on-line submission only.

Note:  The data may be altered/corrected/added to before Feb. 20th.

 

Purpose:

The purpose of this assignment is to gain some experience with the XML languages XPath and XQuery.

 

Rules/Background:

You are to work alone on this assignment.

 

Galax is available on gaul (obelix) in /usr/local/Galax/bin.  You should add /usr/local/Galax/bin to your PATH or run the following command each time you log in:
setenv   PATH   ${PATH}:/usr/local/Galax/bin


Galax has been installed on the linux boxes in MC10.  To reach these machines, you can ssh into gaul, and then ssh into

lxf-xxx.gaul.csd.uwo.ca where xxx is a number from 001 to 036 (except no 002, 008, 013, 016, 018, 022 or 029).  In the linux environment, galax has been installed in /usr/bin which is probably in your path.  Run it with galax-run as in the tutorial.

Galax information is also found on http://galax.sourceforge.net.

 

You can also download eXist-db from eXist-db.org, or Altova Spy from www.altova.com to do this assignment.

 

Part 0, Schema and Data Files:
I have prepared a file of contestants and songs.  If you use Galax, you can use a context file or put the declare variable statements right in the query file. 

 

These questions also make use of the XML version of Shakespeare’s Macbeth.

 

Part 1, XPath

For these questions, you need to hand in a copy of the XPath and a copy of the answer you obtained by running the XPath on one of the above systems.

1.   Give an XPath query and its answer to show where the word “bubble” appears in Macbeth.  Return the speech.

2.   Give an XPath query and its answer to list characters in Macbeth who have lines containing the word “dost”.

3.   Give an XPath query and its answer to count songs in the songs file composed by Paul McCartney.

4.   Give an XPath query and its answer to show songs in the songs file whose titles contain the word “and”.

5.   Give an XPath query and its answer to show the singers who have a performance which includes a song composed by Paul McCartney.  Just put the singers’ names in the answer.

                                                                                                                                                    

Part 2, XQuery


Using FLWOR queries, show XQuery expressions and the answers obtained for the following:

 

1.   Give a FLWOR query and its answer to show the speakers in Macbeth, ordered by name.

2.   Give a FLWOR query and its answer to show, for each speaker in Macbeth, the number of speeches they have.

3.   Give a FLWOR query and its answer to show the names of singers whose hometown contains the letter “i” (lower case i).

4.   Give a FLWOR query and its answer to show the performers who have a song in their repertoire composed by themself.

5.   Give a FLWOR query and its answer to show the performer name where there is a song by Paul McCartney in one of their performances.

6.   Give a FLWOR query and its answer to show the names of performers who have performed a song not listed in their repertoire.

7.   Give a FLWOR query and its answer to show the names of performers, and then for each performer, a list of the composers of the songs in their repertoire.  Make this a well-formed XML document.

8.   Give a FLWOR query and its answer to show all performers who have a performance such that all the songs in that performance are composed by themselves. 

9.   Give a FLWR query and its answer which produces a well-formed XML document, containing each performer in the contestants file, and then a list of their performances, with dates, where each performance is shown as a list of the titles of the songs performed.

10.               Give a FLWR query and its answer to show, for each song, the title, and a list of the performers and dates such that that song is in a performance on that date.

11.               Is the XQuery system you are using closed?  Show why or why not with an example. 

 

What to hand in:

 

You are to submit your assignment electronically using the submit command on gaul.  For each question, submit the query as a file and the answer as a file, suitably named.  Include a readme file which explains which system you used, and anything else you think needs to be explained.  Part 2, Q. 11 can be submitted as a single file explaining what you did, including any answers you got from the XQuery system.