X-Git-Url: http://matita.cs.unibo.it/gitweb/?p=helm.git;a=blobdiff_plain;f=helm%2FDEVEL%2Fpxp%2Fpxp%2Fexamples%2Fsimple_transformation%2Fsort.ml;fp=helm%2FDEVEL%2Fpxp%2Fpxp%2Fexamples%2Fsimple_transformation%2Fsort.ml;h=0000000000000000000000000000000000000000;hp=297730f667d4463bda1d912a4667de8d8d0dcc9e;hb=869549224eef6278a48c16ae27dd786376082b38;hpb=89262281b6e83bd2321150f81f1a0583645eb0c8 diff --git a/helm/DEVEL/pxp/pxp/examples/simple_transformation/sort.ml b/helm/DEVEL/pxp/pxp/examples/simple_transformation/sort.ml deleted file mode 100644 index 297730f66..000000000 --- a/helm/DEVEL/pxp/pxp/examples/simple_transformation/sort.ml +++ /dev/null @@ -1,83 +0,0 @@ -(* $Id$ - * ---------------------------------------------------------------------- - * - *) - -(* Read a record-list, sort it, and print it as XML *) -open Pxp_types;; -open Pxp_document;; -open Pxp_yacc;; - -let sort by tree = - map_tree - ~pre: - (fun n -> n # orphaned_flat_clone) - ~post: - (fun n -> - match n # node_type with - T_element "record-list" -> - let l = n # sub_nodes in - let l' = List.sort - (fun a b -> - let a_string = - try (find_element by a) # data - with Not_found -> "" in - let b_string = - try (find_element by b) # data - with Not_found -> "" in - Pervasives.compare a_string b_string) - l in - n # set_nodes l'; - n - | _ -> - n) - tree -;; - - -let main() = - let criterion = ref "last-name" in - Arg.parse - [ "-by", Arg.String (fun s -> criterion := s), - " (last-name|first-name|phone)"; - ] - (fun _ -> raise (Arg.Bad "Bad usage")) - "usage: sort [ options ]"; - if not(List.mem !criterion ["last-name"; "first-name"; "phone"]) then ( - prerr_endline ("Unknown criterion: " ^ !criterion); - exit 1 - ); - try - let dtd = parse_dtd_entity default_config (from_file "record.dtd") in - let tree = - parse_content_entity default_config (from_channel stdin) dtd default_spec - in - print_endline ""; - (sort !criterion tree) # write (Out_channel stdout) `Enc_iso88591 - with - x -> - prerr_endline(string_of_exn x); - exit 1 -;; - - -main();; - -(* ====================================================================== - * History: - * - * $Log$ - * Revision 1.1 2000/11/17 09:57:32 lpadovan - * Initial revision - * - * Revision 1.3 2000/08/30 16:05:44 gerd - * Minor update - * - * Revision 1.2 2000/08/24 09:40:11 gerd - * Allow that columns are missing. - * - * Revision 1.1 2000/08/22 21:57:44 gerd - * Initial revision. - * - * - *)