(: OBSOLETED! date: 27-August-2010 author: Gary Lewis note: The procedure for populating whPop.xml is now generalized so it does not require variable specific XQuery programs. See: create_stgPop.xq create_stg2whPop.xq :) (: file: rControl.xq date: 06-August-2010 author: Gary Lewis purpose: Creates one XML for the rControl warehouse variable that includes all survey years. This XML is a staging file for assembly into the warehouse. notes: 1. The logic used to construct the rControl variable depends on the survey years. 2. The file recodes.xml contains the expressions needed to make the rControl calculation for each survey year. 3. The eval{} causes the expression to be be evaluated. 4. The population here refers to the IPEDS xml data files and not to the set of 5602 distinct warehouse institutions. usage: Run from path where program is located. example: zorba -f -q rControl.xq -o rControl.xml -z indent=yes :) { for $i in doc("../xml/metadata/ipedsData.xml")/data/file[@type = "xml"] let $year := $i/@year, $xmlFile := concat($i/@path, $i/@name) order by $year descending return { for $j in doc($xmlFile)/data/record let $unitid := $j/@unitid, $control := if ($j/@control = "") then -9 else xs:integer($j/@control), $affil := if ($j/@affil = "") then -9 else xs:integer($j/@affil), $rControl := for $k in doc("../xml/warehouse/recodes.xml")/variables/var[@rName = "rControl"]/condition[@year = $year]/@expression return using $control, $affil eval{$k} return } }