2 * ----------------------------------------------------------------------
6 (* Read a record-list, sort it, and print it as XML *)
14 (fun n -> n # orphaned_flat_clone)
17 match n # node_type with
18 T_element "record-list" ->
19 let l = n # sub_nodes in
23 try (find_element by a) # data
24 with Not_found -> "" in
26 try (find_element by b) # data
27 with Not_found -> "" in
28 Pervasives.compare a_string b_string)
39 let criterion = ref "last-name" in
41 [ "-by", Arg.String (fun s -> criterion := s),
42 " (last-name|first-name|phone)";
44 (fun _ -> raise (Arg.Bad "Bad usage"))
45 "usage: sort [ options ]";
46 if not(List.mem !criterion ["last-name"; "first-name"; "phone"]) then (
47 prerr_endline ("Unknown criterion: " ^ !criterion);
51 let dtd = parse_dtd_entity default_config (from_file "record.dtd") in
53 parse_content_entity default_config (from_channel stdin) dtd default_spec
55 print_endline "<?xml encoding='ISO-8859-1'?>";
56 (sort !criterion tree) # write (Out_channel stdout) `Enc_iso88591
59 prerr_endline(string_of_exn x);
66 (* ======================================================================
70 * Revision 1.1 2000/11/17 09:57:32 lpadovan
73 * Revision 1.3 2000/08/30 16:05:44 gerd
76 * Revision 1.2 2000/08/24 09:40:11 gerd
77 * Allow that columns are missing.
79 * Revision 1.1 2000/08/22 21:57:44 gerd