Commit 37fb0285 authored by Pietro Abate's avatar Pietro Abate

[r2005-03-08 14:36:53 by afrisch] New PXP resolver

Original author: afrisch
Date: 2005-03-08 14:36:53+00:00
parent 7e95f821
type url = Filename of string | Url of string
val is_url: string -> bool
val process: string -> url
val local: string -> string -> string
......
......@@ -19,32 +19,38 @@ let pxp_config =
}
let get_uri uri =
match Url.process uri with
| Url.Filename s -> Url.load_file s
| Url.Url s -> s
let channel_of_id rid =
match rid.rid_system_base, rid.rid_system with
| Some base, Some local ->
let uri = Url.local base local in
(* Printf.printf "base=%s local=%s ==> %s\n" base local uri; *)
let ch = new Netchannels.input_string (get_uri uri) in
let id = { rid with rid_system = Some uri } in
ch, None, Some id
| _ -> raise Not_competent
let alt = [ new resolve_to_any_obj_channel ~channel_of_id () ]
let url =
match rid.rid_system_base, rid.rid_system with
| Some base, Some rel -> Url.local base rel
| _, Some rel -> rel
| _ -> raise Not_competent
in
let ch =
if Url.is_url url
then new Netchannels.input_string (!Url.load_url url)
else new Netchannels.input_channel (open_in_bin url)
in
ch, None, Some { rid with rid_system = Some url }
let alt = new resolve_to_any_obj_channel ~channel_of_id ()
let load_pxp uri =
try
let src = from_string ~alt ~system_id:uri (get_uri uri) in
let src = XExtID (System uri,None,alt) in
let mgr = create_entity_manager pxp_config src in
process_entity pxp_config
(`Entry_document[`Extend_dtd_fully]) mgr pxp_handle_event;
with exn ->
raise (Location.Generic (Pxp_types.string_of_exn exn))
(*
let channel_or_url id url =
let data = !Url.load_url (Neturl.string_of_url url) in
let ch = new Netchannels.input_string data in
(data, None, None)
*)
let use () = Load_xml.xml_parser := load_pxp
let () =
......
val use: unit -> unit
(* Call this function from a stand-alone OCaml program
to activate PXP *)
......@@ -618,7 +618,7 @@ let schema_of_uri uri =
i "http://www.w3.org/2001/xml.xsd"
| Some ns ->
print_endline ("Import with no schemaLocation but a namespace:"^(Utf8.get_str ns));
print_endline "Trying to use the namespace as a URI...";
print_endline "Trying to use namespace as URI...";
i (Utf8.get_str ns)
| _ ->
print_endline "Import ignored, no schemaLocation")
......
......@@ -44,24 +44,24 @@ let node_of src =
open Pxp_types
open Pxp_reader
let get_uri uri =
match Url.process uri with
| Url.Filename s -> Url.load_file s
| Url.Url s -> s
let channel_of_id rid =
match rid.rid_system_base, rid.rid_system with
| Some base, Some local ->
let uri = Url.local base local in
let ch = new Netchannels.input_string (get_uri uri) in
let id = { rid with rid_system = Some uri } in
ch, None, Some id
| _ -> raise Not_competent
let url =
match rid.rid_system_base, rid.rid_system with
| Some base, Some rel -> Url.local base rel
| _, Some rel -> rel
| _ -> raise Not_competent
in
let ch =
if Url.is_url url
then new Netchannels.input_string (!Url.load_url url)
else new Netchannels.input_channel (open_in_bin url)
in
ch, None, Some { rid with rid_system = Some url }
let alt = [ new resolve_to_any_obj_channel ~channel_of_id () ]
let alt = new resolve_to_any_obj_channel ~channel_of_id ()
let node_of_uri uri =
try node_of (from_string ~alt ~system_id:uri (get_uri uri))
try node_of (XExtID (System uri,None,alt))
with exn -> raise (Location.Generic (Pxp_types.string_of_exn exn))
let _may_attr name n =
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment