]> matita.cs.unibo.it Git - helm.git/blob - helm/DEVEL/pxp/pxp/rtests/write/test_write.ml
Initial revision
[helm.git] / helm / DEVEL / pxp / pxp / rtests / write / test_write.ml
1 (* $Id$
2  * ----------------------------------------------------------------------
3  *
4  *)
5
6
7 open Pxp_document;;
8 open Pxp_yacc;;
9 open Pxp_types;;
10
11 let error_happened = ref false;;
12
13 let rec prerr_error e =
14   prerr_endline (string_of_exn e)
15 ;;
16
17 class warner =
18   object 
19     method warn w =
20       prerr_endline ("WARNING: " ^ w)
21   end
22 ;;
23
24 let parse_and_write in_filename =
25   let spec =
26     let e = new element_impl default_extension in
27     make_spec_from_mapping
28       ~super_root_exemplar:      e
29       ~default_pinstr_exemplar:  e
30       ~data_exemplar:            (new data_impl default_extension)
31       ~default_element_exemplar: e
32       ~element_mapping:          (Hashtbl.create 1)
33       ()
34   in
35   let config =
36       { default_config with 
37           warner = new warner;
38           enable_pinstr_nodes = true;
39           enable_super_root_node = true;
40           encoding = `Enc_utf8;
41       }
42   in
43   try 
44     let tree =
45       parse_document_entity
46         config
47         (from_file in_filename)
48         spec 
49     in
50     
51     tree # write (Out_channel stdout) `Enc_utf8;
52   with
53       e ->
54         error_happened := true;
55         prerr_error e
56 ;;
57
58
59 let main() =
60   let in_file = ref "" in
61   Arg.parse
62       [ "-in", (Arg.String (fun s -> in_file := s)),
63             " <file>      Set the XML file to read";
64       ]
65       (fun x -> raise (Arg.Bad "Unexpected argument"))
66       "
67 usage: test_write [ options ]
68
69 List of options:";
70   if !in_file = "" then begin
71     prerr_endline "No input file specified.";
72     exit 1
73   end;
74   parse_and_write !in_file 
75 ;;
76
77
78 main();
79 if !error_happened then exit(1);;
80
81 (* ======================================================================
82  * History:
83  * 
84  * $Log$
85  * Revision 1.1  2000/11/17 09:57:35  lpadovan
86  * Initial revision
87  *
88  * Revision 1.2  2000/08/16 23:44:21  gerd
89  *      Updates because of changes of the PXP API.
90  *
91  * Revision 1.1  2000/07/16 17:50:39  gerd
92  *      Initial revision.
93  *
94  *)