(: file: create_initial_rVariables_1var.xq date: 31-August-2010 author: Gary Lewis purpose: Lists metadata for one specified variable for one specified year. Done in such a way that the output can be concatenated to rVariables.xml and then edited lightly. Most useful when the variable has many code values and labels. usage: Run from path where program is located. example: zorba -e rVar:="rState" -e var:="fips" -e year:="2008" -f -q create_initial_rVariables_1var.xq -o initial_rVariables_fips.xml -z indent=yes :) declare variable $rVar external; declare variable $var external; declare variable $year external; { let $j := doc("../xml/metadata/ipedsVars_metadata.xml")/variables/var[@name = $var]/detail[@year = $year], $dataType := $j/@dataType, $fieldWidth := $j/@fieldWidth return { for $i in doc("../xml/metadata/ipedsVars_metadata_codes.xml")/variables/var[@name = $var][@year = $year]/code let $value := if ($dataType = "N") then xs:integer($i/@value) else $i/@value, $label := $i/@label order by $value ascending return } }