| 1 |
abate |
1187 |
open Pxp_yacc
|
| 2 |
|
|
open Pxp_lexer_types
|
| 3 |
|
|
open Pxp_types
|
| 4 |
abate |
1260 |
open Pxp_ev_parser
|
| 5 |
abate |
1187 |
|
| 6 |
|
|
let pxp_handle_event = function
|
| 7 |
abate |
1260 |
| E_start_tag (name,att,_,_) -> Load_xml.start_element_handler name att
|
| 8 |
abate |
1187 |
| E_char_data data -> Load_xml.text_handler data
|
| 9 |
|
|
| E_end_tag (_,_) -> Load_xml.end_element_handler ()
|
| 10 |
|
|
| _ -> ()
|
| 11 |
|
|
|
| 12 |
|
|
let pxp_config =
|
| 13 |
|
|
{ default_config with
|
| 14 |
|
|
(* warner = new warner; *)
|
| 15 |
|
|
encoding = `Enc_utf8;
|
| 16 |
|
|
store_element_positions = false;
|
| 17 |
|
|
drop_ignorable_whitespace = true
|
| 18 |
|
|
}
|
| 19 |
|
|
|
| 20 |
|
|
|
| 21 |
|
|
let load_pxp s =
|
| 22 |
|
|
try
|
| 23 |
|
|
let src =
|
| 24 |
abate |
1411 |
match s with
|
| 25 |
abate |
1187 |
| Url.Url s -> from_string s
|
| 26 |
|
|
| Url.Filename s -> from_file s in
|
| 27 |
|
|
let mgr = create_entity_manager pxp_config src in
|
| 28 |
|
|
process_entity pxp_config (`Entry_document[`Extend_dtd_fully]) mgr pxp_handle_event;
|
| 29 |
|
|
with exn ->
|
| 30 |
|
|
raise (Location.Generic (Pxp_types.string_of_exn exn))
|
| 31 |
|
|
|
| 32 |
abate |
1188 |
let () =
|
| 33 |
|
|
Config.register
|
| 34 |
|
|
"pxp"
|
| 35 |
|
|
"PXP XML parser"
|
| 36 |
|
|
(fun () -> Load_xml.xml_parser := load_pxp)
|