Commit fe12c813 authored by Pietro Abate's avatar Pietro Abate
Browse files

[r2003-12-01 16:40:46 by afrisch] Cosmetique

Original author: afrisch
Date: 2003-12-01 16:43:22+00:00
parent ddab04c5
......@@ -14,6 +14,6 @@ let load_url s =
perform conn;
Buffer.contents buff
let process_url s =
let process s =
if is_url s then Url (load_url s)
else Filename s
......@@ -5,4 +5,4 @@ type url = Filename of string | Url of string
* in a string otherwise consider it as filename
*)
val process_url: string -> url
val process: string -> url
......@@ -112,7 +112,7 @@ EXTEND
[ mk loc (Using (U.mk name, Types.CompUnit.mk (U.mk cu))) ]
| "schema"; name = IDENT; "="; uri = STRING2 ->
protect_op "schema";
let schema = match Url.process_url uri with
let schema = match Url.process uri with
| Url.Filename s -> Schema_parser.schema_of_file s
| Url.Url s -> Schema_parser.schema_of_string s in
[ mk loc (SchemaDecl (U.mk name, schema)) ]
......
......@@ -13,10 +13,6 @@ open Pxp_types
open Value
open Ident
open Encodings
open List
open Url
type buf =
......@@ -158,10 +154,11 @@ let pxp_config =
let load_pxp s =
try
let mgr = create_entity_manager pxp_config
(match s with
| Url(s) -> from_string s
| Filename(s) -> from_file s ) in
let src =
match s with
| Url.Url s -> from_string s
| Url.Filename s -> from_file s 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))
......@@ -173,7 +170,7 @@ let load_xml s =
try
(match !use_parser with
| `Expat -> load_expat s
| `Pxp -> load_pxp (process_url s));
| `Pxp -> load_pxp (Url.process s));
match !stack with
| [ Element x ] -> stack := []; x
| _ -> assert false
......@@ -194,18 +191,16 @@ let load_html s =
in
Location.protect_op "load_html";
match process_url s with
| Filename(s) -> (
let ic = open_in s in
let doc = Nethtml.parse_document
~dtd:Nethtml.relaxed_html40_dtd
(Lexing.from_channel ic) in
let doc = Nethtml.decode ~enc:`Enc_utf8 ~subst:(fun _ -> "???") doc in
close_in ic;
val_of_docs doc)
| Url s -> (
let doc = Nethtml.parse_document
~dtd:Nethtml.relaxed_html40_dtd
(Lexing.from_string s) in
let doc = Nethtml.decode ~enc:`Enc_utf8 ~subst:(fun _ -> "???") doc in
val_of_docs doc)
let parse src = Nethtml.parse_document ~dtd:Nethtml.relaxed_html40_dtd src in
let doc =
match Url.process s with
| Url.Filename s ->
let ic = open_in s in
let doc = parse (Lexing.from_channel ic) in
close_in ic;
doc
| Url.Url s ->
parse (Lexing.from_string s)
in
val_of_docs (Nethtml.decode ~enc:`Enc_utf8 ~subst:(fun _ -> "???") doc)
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