(: file: dyn_create_stgPop_all_1year.xq date: 26-August-2010 author: Gary Lewis purpose: Creates a shell script that, when run, will extract from each IPEDS data file only those variables needed for staging. notes: 1. This creates much smaller individual year-specific data files for processing and improves performance. usage: Run from path where program is located. example: zorba -f -q dyn_create_stgPop_all_1year.xq -o ../sh/create_stgPop_all_1year.sh -z method=text :) let $dq := """", $nl := " ", $dateTime := format-dateTime(current-dateTime(), "[D]-[MNn]-[Y] [H01]:[m01][Pn] [ZN]"), $tmp1 := text{concat( "#!/bin/sh",$nl,$nl, "# file: create_stgPop_all_1year.sh",$nl, "# date: ",$dateTime,$nl, "# author: Program created by dyn_create_stgPop_all_1year.xq.",$nl, "# purpose: Creates stgPop_{$year}.xml in ~/rwebdb/projects/ipeds/xml/staging for",$nl, "# each $year where an IPEDS data file exists. This reduces the size of the",$nl, "# data files needed to process staging variables.",$nl, "# usage: Run this program from the location of create_stgPop_1year.xq in",$nl, "# ~/rwebdb/projects/ipeds/xquery.",$nl, "# example: bash ../sh/create_stgPop_all_1year.sh",$nl,$nl, "rm /home/gml/rwebdb/projects/ipeds/xml/staging/stgPop.xml",$nl, "rm /home/gml/rwebdb/projects/ipeds/xml/staging/stgPop_*.xml",$nl )}, $tmp2 := 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 text{concat( "zorba -e xmlFile:=",$dq,$xmlFile,$dq," -e year:=",$dq,$year,$dq," -f -q create_stgPop_1year.xq -o /home/gml/rwebdb/projects/ipeds/xml/staging/stgPop_",$year,".xml -z indent=yes",$nl )} return ($tmp1, $tmp2)