/[svn]/runtime/cduce_expat.ml
ViewVC logotype

Contents of /runtime/cduce_expat.ml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1187 - (hide annotations)
Tue Jul 10 18:29:32 2007 UTC (5 years, 10 months ago) by abate
File size: 1276 byte(s)
[r2004-06-29 23:06:06 by afrisch] Cleanup. Remove options --pxp and --expat

Original author: afrisch
Date: 2004-06-29 23:06:08+00:00
1 abate 1187 let buflen = 1024
2     let buf = String.create buflen
3    
4     let load_from_file p s =
5     let ic =
6     try open_in s
7     with exn ->
8     let msg =
9     Printf.sprintf "load_xml, file \"%s\": %s" s (Printexc.to_string exn)
10     in
11     raise (Location.Generic msg)
12     in
13     let rec loop () =
14     let n = input ic buf 0 buflen in
15     if (n > 0) then (Expat.parse_sub p buf 0 n; loop ())
16     in
17     try
18     loop();
19     Expat.final p;
20     close_in ic
21     with exn -> close_in ic; raise exn
22    
23     let load_expat s =
24     let p = Expat.parser_create "" in
25     Expat.set_start_element_handler p Load_xml.start_element_handler;
26     Expat.set_end_element_handler p Load_xml.end_element_handler;
27     Expat.set_character_data_handler p Load_xml.text_handler;
28     try
29     match Url.process s with
30     | Url.Url s -> Expat.parse p s
31     | Url.Filename s -> load_from_file p s
32     with Expat.Expat_error e ->
33     let line = Expat.get_current_line_number p
34     and col = Expat.get_current_column_number p in
35     let msg =
36     Printf.sprintf
37     "load_xml, file \"%s\", at line %i, column %i: %s"
38     s
39     (Expat.get_current_line_number p)
40     (Expat.get_current_column_number p)
41     (Expat.xml_error_to_string e)
42     in
43     raise (Location.Generic msg)
44    
45     let () =
46     Load_xml.xml_parser := load_expat;
47     Config.pxp_support := true

CVS Admin">CVS Admin
ViewVC Help
Powered by ViewVC 1.1.5