]> matita.cs.unibo.it Git - helm.git/blob - helm/DEVEL/pxp/pxp/examples/simple_transformation/print.ml
Initial revision
[helm.git] / helm / DEVEL / pxp / pxp / examples / simple_transformation / print.ml
1 (* $Id$
2  * ----------------------------------------------------------------------
3  *
4  *)
5
6 (* Read a record-list structure and print it *)
7 open Pxp_types;;
8 open Pxp_document;;
9 open Pxp_yacc;;
10
11 let print tree =
12   iter_tree
13     ~pre:
14       (fun n ->
15          match n # node_type with
16              T_element "last-name" ->
17                print_endline ("Last name: " ^ n # data)
18            | T_element "first-name" ->
19                print_endline ("First name: " ^ n # data)
20            | T_element "phone" ->
21                print_endline ("Telephone number: " ^ n # data)
22            | _ ->
23                ())
24     ~post:
25       (fun n ->
26          match n # node_type with
27              T_element "record" -> 
28                print_newline()
29            | _ ->
30                ())
31     tree
32 ;;
33
34 let main() =
35   try
36     let dtd = parse_dtd_entity default_config (from_file "record.dtd") in
37     let tree = 
38       parse_content_entity default_config (from_channel stdin) dtd default_spec in
39     print tree
40   with
41       x ->
42         prerr_endline(string_of_exn x);
43         exit 1
44 ;;
45
46
47 main();;
48
49 (* ======================================================================
50  * History:
51  * 
52  * $Log$
53  * Revision 1.1  2000/11/17 09:57:32  lpadovan
54  * Initial revision
55  *
56  * Revision 1.1  2000/08/22 21:57:43  gerd
57  *      Initial revision.
58  *
59  * 
60  *)