From: Sava J. <sju...@mr...> - 2006-11-10 20:29:10
|
Wolfgang Meier <wolfgangmm <at> gmail.com> writes: > > In order to test this: how do you modify the nodes? XUpdate? XQuery > update extensions? Just replacing the document? > > Wolfgang > We use XQuery update extension; Also, Wolfgang, the performance of XQuery update vs. XUpdate is way lower; I don't have any banchmarks, but you "see" the performance difference; Here is the sample code: (: Author: Toar Updates patient entry in patientlist collection :) declare function local:do_update($id, $lastname, $firstname, $middlename, $dob, $php, $sex, $phone_area, $phone_number, $cell_phone_area, $cell_phone_number, $work_phone_area, $work_phone_number, $primary_phone) { for $x in xcollection("/db/data/patientlist")/patients/patient[id = $id] return ( update value $x/lastname with $lastname, update value $x/firstname with $firstname, update value $x/middlename with $middlename, update value $x/dob with $dob, update value $x/php with $php, update value $x/sex with $sex, update value $x/phone_area with $phone_area, update value $x/phone_number with $phone_number, update value $x/cell_phone_area with $cell_phone_area, update value $x/cell_phone_number with $cell_phone_number, update value $x/work_phone_area with $work_phone_area, update value $x/work_phone_number with $work_phone_number, if( $x/primary_phone ) then update value $x/primary_phone with $primary_phone else update insert <primary_phone>{$primary_phone}</primary_phone> into $x ) }; declare function local:verify() as node()* { let $id := request:get-parameter("id",""), $lastname := request:get-parameter("lastname",""), $firstname := request:get-parameter("firstname",""), $middlename := request:get-parameter("middlename",""), $dob := request:get-parameter("dob",""), $php := request:get-parameter("php",""), $sex := request:get-parameter("sex",""), $phone_area := request:get-parameter("phone_area",""), $phone_number := request:get-parameter("phone_number",""), $cell_phone_area := request:get-parameter("cell_phone_area",""), $cell_phone_number := request:get-parameter("cell_phone_number",""), $work_phone_area := request:get-parameter("work_phone_area",""), $work_phone_number := request:get-parameter("work_phone_number",""), $primary_phone := request:get-parameter("primary_phone","Home") return <result> {local:do_update($id, $lastname, $firstname, $middlename, $dob, $php, $sex, $phone_area, $phone_number, $cell_phone_area, $cell_phone_number, $work_phone_area, $work_phone_number, $primary_phone)} </result> }; <html> <mrxdata> { local:verify() } </mrxdata> </html> |