1 (******************************************************************************)
5 (* Claudio Sacerdoti Coen <sacerdot@cs.unibo.it> *)
9 (******************************************************************************)
13 "http://localhost:8081/getdtd?url=cic.dtd" ->
14 Configuration.dtd_dir ^ "/cic.dtd"
15 | "http://localhost:8081/getdtd?url=maththeory.dtd" ->
16 Configuration.dtd_dir ^ "/maththeory.dtd"
17 | "http://localhost:8081/getdtd?url=annotations.dtd" ->
18 Configuration.dtd_dir ^ "/annotations.dtd"
25 `Not_recognized -> Neturl.Url_part_not_recognized
26 | `Allowed -> Neturl.Url_part_allowed
27 | `Required -> Neturl.Url_part_required
29 { Neturl.null_url_syntax with
30 Neturl.url_enable_scheme = enable_if `Allowed;
31 Neturl.url_enable_host = enable_if `Allowed;
32 Neturl.url_enable_path = Neturl.Url_part_required;
33 Neturl.url_accepts_8bits = true;
37 let file_url_of_id xid =
38 let file_url_of_sysname sysname =
39 (* By convention, we can assume that sysname is a URL conforming
40 * to RFC 1738 with the exception that it may contain non-ASCII
44 Neturl.url_of_string url_syntax sysname
45 (* may raise Malformed_URL *)
47 Neturl.Malformed_URL -> raise Pxp_reader.Not_competent
51 Pxp_types.Anonymous -> raise Pxp_reader.Not_competent
52 | Pxp_types.Public (_,sysname) ->
53 let sysname = resolve sysname in
54 if sysname <> "" then file_url_of_sysname sysname
55 else raise Pxp_reader.Not_competent
56 | Pxp_types.System sysname ->
57 let sysname = resolve sysname in
58 file_url_of_sysname sysname
61 try Neturl.url_scheme url with Not_found -> "file" in
63 try Neturl.url_host url with Not_found -> "" in
65 if scheme <> "file" then raise Pxp_reader.Not_competent;
66 if host <> "" && host <> "localhost" then raise Pxp_reader.Not_competent;
71 let from_file ?system_encoding utf8_filename =
74 new Pxp_reader.resolve_as_file
75 ?system_encoding:system_encoding
76 ~url_of_id:file_url_of_id
80 let utf8_abs_filename =
81 if utf8_filename <> "" && utf8_filename.[0] = '/' then
84 Sys.getcwd() ^ "/" ^ utf8_filename
87 let syntax = { Neturl.ip_url_syntax with Neturl.url_accepts_8bits = true } in
88 let url = Neturl.make_url
91 ~path:(Neturl.split_path utf8_abs_filename)
95 let xid = Pxp_types.System (Neturl.string_of_url url) in
98 Pxp_yacc.ExtID(xid, r)