==================================================================== Saxon Instructions (Linux+Java only) ===================================================================== Saxon comes in Java or .NET versions. 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). Create a directory for the assignment and cd into that directory, then do the following: 0. 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[normalize-space(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. The normalize-space function takes any non-single-space whitespace (newline, tab, consecutive spaces, etc) and replaces them with a single space, and removes all leading and trailing spaces. You may want to consider using this function when dealing with strings you cannot control (like strings from variables). :) 1. Download and unzip the java version of the saxon home edition. $ wget http://sourceforge.net/projects/saxon/files/latest/download?source=files -O saxonhe9.zip $ unzip saxonhe9.zip 2. Get the mondial.xml and dtd by downloading and opening hw5.tar.gz 3. Make sure to move or copy the saxonhe9.jar, mondial.xml, and mondial.dtd files are in the same directory as the query files. 3. Run the program $ java -cp saxon9he.jar net.sf.saxon.Query q1.xq $ java -cp saxon9he.jar net.sf.saxon.Query q2.xq The results are horrible. 4. To pretty-print, do this: $ java -cp saxon9he.jar net.sf.saxon.Query q1.xq > a1.xml $ xmllint --format a1.xml $ $ java -cp saxon9he.jar net.sf.saxon.Query q2.xq > a2.xml $ xmllint --format a2.xml 5. As a check, with xmllint formatting, the output for query 2 should look like this: $ java -cp saxon9he.jar net.sf.saxon.Query q2.xq > a2.xml $ xmllint --format a2.xml Ancash Ica Piura Puno