3 * - XmlPushParser version *)
7 let print s = print_endline s; flush stdout
10 { default_callbacks with
12 Some (fun tag attrs ->
13 let length = List.length attrs in
14 print (sprintf "opening %s [%s]"
15 tag (String.concat ";" (List.map fst attrs))));
16 end_element = Some (fun tag -> print ("closing " ^ tag));
17 character_data = Some (fun data -> print "character data ...");
20 let xml_parser = create_parser callbacks
24 let len = String.length f in
25 String.sub f (len - 3) 3 = ".gz"
26 with Invalid_argument _ -> false
30 if is_gzip Sys.argv.(1) then
31 `Gzip_file Sys.argv.(1)
35 parse xml_parser xml_source
38 * - Pure expat version (without XmlPushParser mediation).
39 * Originally written only to test if XmlPushParser mediation caused overhead.
40 * That was not the case. *)
43 (* let ic = open_in Sys.argv.(1) in*)
44 (* let expat_parser = Expat.parser_create ~encoding:None in*)
45 (* Expat.set_start_element_handler expat_parser*)
46 (* (fun tag attrs ->*)
47 (* let length = List.length attrs in*)
48 (* print (sprintf "opening %s [%d attribute%s]"*)
49 (* tag length (if length = 1 then "" else "s")));*)
50 (* Expat.set_end_element_handler expat_parser*)
51 (* (fun tag -> print ("closing " ^ tag));*)
52 (* Expat.set_character_data_handler expat_parser*)
53 (* (fun data -> print "character data ...");*)
56 (* Expat.parse expat_parser (input_line ic ^ "\n")*)
58 (* with End_of_file -> Expat.final expat_parser*)