1
(************************************************************************)
2
(* v * The Coq Proof Assistant / The Coq Development Team *)
3
(* <O___,, * CNRS-Ecole Polytechnique-INRIA Futurs-Universite Paris Sud *)
4
(* \VV/ **************************************************************)
5
(* // * The HELM Project / The EU MoWGLI Project *)
6
(* * University of Bologna *)
7
(************************************************************************)
8
(* This file is distributed under the terms of the *)
9
(* GNU Lesser General Public License Version 2.1 *)
11
(* Copyright (C) 2000-2004, HELM Team. *)
12
(* http://helm.cs.unibo.it *)
13
(************************************************************************)
15
(* the type token for XML cdata, empty elements and not-empty elements *)
18
(* Empty (element_name, [attrname1, value1 ; ... ; attrnamen, valuen] *)
19
(* NEmpty (element_name, [attrname1, value2 ; ... ; attrnamen, valuen], *)
21
type token = Str of string
22
| Empty of string * (string * string) list
23
| NEmpty of string * (string * string) list * token Stream.t
26
(* currified versions of the constructors make the code more readable *)
27
let xml_empty name attrs = [< 'Empty(name,attrs) >]
28
let xml_nempty name attrs content = [< 'NEmpty(name,attrs,content) >]
29
let xml_cdata str = [< 'Str str >]
32
(* pp tokens None pretty prints the output on stdout *)
33
(* pp tokens (Some filename) pretty prints the output on the file filename *)
34
let pp_ch strm channel =
39
fprint_string (a ^ "\n") ;
41
| [< 'Empty(n,l) ; s >] ->
43
fprint_string ("<" ^ n) ;
44
List.iter (function (n,v) -> fprint_string (" " ^ n ^ "=\"" ^ v ^ "\"")) l;
45
fprint_string "/>\n" ;
47
| [< 'NEmpty(n,l,c) ; s >] ->
49
fprint_string ("<" ^ n) ;
50
List.iter (function (n,v) -> fprint_string (" " ^ n ^ "=\"" ^ v ^ "\"")) l;
54
fprint_string ("</" ^ n ^ ">\n") ;
58
for i = 1 to m do fprint_string " " done
59
and fprint_string str =
60
output_string channel str
69
let filename = filename ^ ".xml" in
70
let ch = open_out filename in
73
print_string ("\nWriting on file \"" ^ filename ^ "\" was succesful\n");