



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!




In this exercise, you will write queries over an XML data set using the XQuery language. You will execute your queries using the open-source Saxon system, which we have installed in the class directory space on the EdLab machines: /courses/cs400/cs445/cs445/saxon In order to run Saxon to produce query results, take the following steps: ( i ) Basic setup Go to your home directory, and set your $PATH and $CLASSPATH variables as follows: elnux4>bash bash$ export PATH=/exp/rcf/edlab/jdk1.5.0_01/bin/:$PATH bash$ export CLASSPATH=/courses/cs400/cs445/cs445/saxon/saxon9.jar: $CLASSPATH bash$ export CLASSPATH=/courses/cs400/cs445/cs445/saxon/:$CLASSPATH ( ii ) Data files The XML document “bib.xml” is placed on edlab machines under the following path: /usr/net/ftp/pub/cs645/s2009/hw The DTD of this file, “bib.dtd”, is available in the same directory as the document. The DTD can be very helpful to you in understanding the structure of the document and formulating your queries. A visualized presentation of the dtd is provided in the subdirectory “livedtd- bib/index.html”. You can navigate through the hyperlinks to familiarize yourself with the elements and attributes in this DTD. The second XML document “dblp-sigmod.xml,” its DTD “dblp.dtd,” and its visualized presentation “livedtd-dblp” are available in the same directory. Make a subdirectory “hw5” in your 645 directory. Copy both the XML documents and the DTDs to the “hw5” subdirectory. ( iii ) Query files For each question below, compose an XQuery query. Use the doc() function in your query to address the XML document. For example, the following query retrieves all book elements from the “bib.xml” file. doc(“bib.xml”)/bib/book Store each query in a separate file. Follow the naming convention of Qi.xq for the ith^ query, e.g., “Q1.xq” for the first query, “Q2.xq” for the second, and so on.
( iv ) Qu ery execution After a query is composed, run it using the following command: bash$ java net.sf.saxon.Query Q1.xq In this assignment, you are asked to store the result of each query in a separate file. To do so, type: bash$ java net.sf.saxon.Query Q1.xq > Q1.res ( v ) Submission After you finish this exercise, you should have the following files (Qi.xq, Qi.res), i = 1, 2, …, 8 in your “645/hw5” directory. We will evaluate your solution to this exercise directly from your “hw5” directory on the edlab machines. Note that you can setup Saxon on your own machine and try some queries there. But, make sure to generate the final query results on the EdLab machines, as Unix and Windows use different formats for text files. Q u eries over bib.xml The first XML data set you will be running queries over is a bibliography file. The DTD of this file, “bib.dtd”, is available in the same directory as the data. The DTD can be tremendously helpful to you in understanding the structure of the data and formulating your queries. A visualized presentation of the dtd is also provided in the data directory under the path “livedtd- bib/index.html”. You can navigate through the hyperlinks to familiarize yourself with the elements and attributes in this DTD.
Q u eries over dblp.xml The second XML data set is a DBLP file containing all the publications of ACM SIGMOD up to year 2000. The DTD of this file, “dblp.dtd”, is available in the same directory as the data. The dtd can also be visualized using “livedtd-dblp/index.html”. This DTD is more complex than the previous one. You may want to browse the DTD and the data file at the same time to get familiar with the elements and attributes used in the data. The dblp DTD uses entity declarations to define a set of element names that are used in multiple places in the DTD. Among the commonly used elements, the “proceedings” elements define the proceedings while the “inproceedings” elements refer to the papers included in the proceedings. Each inproceedings element contains a key attribute that uniquely identifies the paper across all SIGMOD publications. An inproceedings element can contain multiple “cite” elements, each referring to another inproceedings element by including in its text content the key value of the referenced element.
/usr/net/ftp/pub/cs645/s2009/hw5/real_temperature200.txt
stream_engine.Execute(); … }
Submission. After you finish this exercise, please also leave your Java files in your “645/hw5” directory.