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