==================================================================== Zorba Instructions (For Saxon instruction see below) ===================================================================== 1. First make sure zorba has been installed on your computer. 2. Open a command prompt (on windows) or a terminal (on linux or MacOSX). 3. Second, make sure zorba is on the path. - On linux/MacOSX, type in $ PATH=$PATH:/path/to/zorba - On Windows (set the path to where you installed zorba).. > set PATH=%PATH%;"C:\Program Files\Zorba XQuery Processor 1.4.0\bin" 4. Download the "mondial.xml" from the link on the hw6 page. 5. Open a text editor of your own choice and save the following in q1.xq (uptil the end of ): { for $x in doc("mondial.xml")/mondial/country//city/name/text() return { $x } } Similarly save the following in q2.xq. { for $x in doc("mondial.xml")/mondial/country[name="Peru"]/province[count(city)>1]/name return { fn:string($x) } } (: Comment :) (: !!! Note: Using "fn:string" is because $x is an attribute. This is one way to return the value of an attribute. :) 6. Now type: $ zorba -i -f -q q1.xq In a few seconds galax will print the result for you. In this case it's the list of all city names in the database. Notice that cities occur either under country, or under province. In order to get both we used country//city. 7. Now try $ zorba -i -f -q q2.xq You are getting the names of all provinces in Peru with at least two cities. 8. Finally, try: $ zorba -i -f -q q2.xq > myfile.xml This creates myfile.xml in the current directory with your result. ==================================================================== Saxon Instruction (Linux+Java only, modify them for windows) ===================================================================== Saxon comes in Java or .NET version. The documentation for the command line version of either is available at: http://www.saxonica.com/documentation/using-xquery/commandline.xml To download either version navigate to: http://sourceforge.net/projects/saxon/files/ (The instructions below will download saxon Java version from scratch). 0. Assuming that you have the q1.xq and q2.xq created with the contents shown above (step 5 only). 1. Navigate to the hw directory $ cd hw6 # Alternatively $ mkdir hw6 && cd $_ 2. Download the java version of the saxon home edition. $ wget http://sourceforge.net/projects/saxon/files/Saxon-HE/9.3/saxonhe9-3-0-1j.zip/download 3. Unzip saxon $ unzip saxonhe9-3-0-1j.zip 4. Get the mondial.xml and dtd (if not already done before) $ wget http://www.cs.washington.edu/education/courses/csep544/10au/hw/hw6/mondial.xml $ wget http://www.cs.washington.edu/education/courses/csep544/10au/hw/hw6/mondial.dtd 5. Run the program $ java -cp saxon9he.jar net.sf.saxon.Query q1.xq