Download The demexp Book - Linux

Transcript
41.9.2
XML import
Helper function responses of cduce xml transforms a Xml’s responses array into a response array compatible with in memory Position base.
240a
hposbase.ml 232ai+≡
/ 239c 240b .
let responses_of_cduce_xml responses_array =
let to_mem response =
{ r_desc = response.Xml.r_desc;
r_author
= Participants.unsafe_authenticated_of_string response.Xml.r_author;
external_link
= match response.Xml.r_links with
| [] -> None
| [ link ] -> Some link
| _ -> failwith "internal error: should not have several links"; } in
Array.map to_mem responses_array
Helper function votes of cduce xml transforms a Xml’s votes list into a data structure
compatible with in memory Position base.
240b
hposbase.ml 232ai+≡
/ 240a 241a .
let votes_of_cduce_xml votes_list =
let votes_h = Hashtbl.create 3 in
let of_list v =
let voter =
match v.Xml.voter with
| name when Participants.delegate_naming name ->
Delegate (Participants.unsafe_authenticated_of_string name)
| name -> Individual name in
Hashtbl.add votes_h voter v.Xml.choices in
List.iter of_list votes_list;
votes_h
240