(: OBSOLETED! date: 22-June-2010 author: Gary Lewis notes: This program and count_distinct_unitids_all_years.xq are replaced by count_distinct_unitids_all_years_v2.xq. This was done to eliminate the need for the 25 files distinct_unitids_by_year.xml (ie 1 file for each year in the time series). For more detail, see count_distinct_unitids_all_years_v2.xq. :) (: file: gen_xq_distinct_unitids_all_years.xq date: 20-May-2010 author: Gary Lewis purpose: Creates an XQuery program called count_distinct_unitids_all_years.xq that when run provides a distinct count of institutions in the 25 years of IPEDS directory data files. usage: Run this program from its path location. Provide the external variable with the path relative to this program location. example: zorba -e xml_ipedsFiles:="../xml/metadata/ipedsFiles.xml" -f -q gen_xq_distinct_unitids_all_years.xq -o count_distinct_unitids_all_years.xq -z method=text :) declare variable $xml_ipedsFiles external; let $nl := " ", $dq := """", $dateTime := format-dateTime(current-dateTime(), "[D]-[MNn]-[Y] [H01]:[m01][Pn] [ZN]"), $tmp0 := text{concat( "(:",$nl, " file: count_distinct_unitids_all_years.xq",$nl, " date: ",$dateTime,$nl, " author: Program created by gen_xq_distinct_unitids_all_years.xq",$nl, " purpose: Provides a distinct count of institutions in the 25 years of IPEDS directory data files",$nl, " usage: Run this program from its path location.",$nl, " Provide the external variable with the path relative to this program location.",$nl, " example: zorba -e xml_ipedsFiles:=",$dq,"../xml/metadata/ipedsFiles.xml",$dq," -f -q count_distinct_unitids_all_years.xq -z indent=yes",$nl, ":)",$nl,"",$nl)}, $tmp1 := text{concat("",$nl,"{",$nl,"let $x := distinct-values((",$nl)}, $tmp3 := text{concat("))",$nl,"return count($x)",$nl,"}",$nl,"",$nl)}, $last := count(fn:doc($xml_ipedsFiles)/ipedsFiles/file[@dir_ind="1"]), $tmp2 := for $i at $j in fn:doc($xml_ipedsFiles)/ipedsFiles/file[@dir_ind="1"] let $ipedsName := $i/@ipedsName, $year := $i/@year, $comma := if ($j != $last) then "," else "", $xml := concat("fn:doc(",$dq,"../",$year,"/",$ipedsName,"/","distinct_unitids_by_year.xml",$dq,")/directory/inst/@unitid",$comma,$nl) return text{$xml} return ($tmp0, $tmp1, $tmp2, $tmp3)