(: file: count_unitid_by_year.xq date: 10-June-2010 author: Gary Lewis purpose: Illustrates the use of metadata files to get a count of unitids (ie, institutions) in each of the IPEDS directory data files. use: Program can be run from any directory. notes: 1. The join between the 2 metadata files occurs in the where clause. It could also have been located in the $j for clause. example: zorba -f -q count_unitid_by_year.xq -z indent=yes revised: 22-June-2010 author: Gary Lewis notes: 1. Added distinct count to the output, so now get a total count and a distinct count of unitids for each year. :) { for $m in ( for $i in fn:doc("/home/gml/rwebdb/projects/ipeds/xml/metadata/ipedsData.xml")/data/file[@type = "xml"] for $j in fn:doc("/home/gml/rwebdb/projects/ipeds/xml/metadata/ipedsFiles.xml")/ipedsFiles/file[@dir_ind = "1"] let $name := $i/@name, $path := $i/@path, $xmlFile := concat($path, $name), $name_wo_ext := substring-before($name, "."), $csvName := $j/@csvName, $year := $j/@year where $csvName = $name_wo_ext (: join between the two xml metadata files :) order by $year return ) return }