From f0e7ce0a6e8c15f198fab4d567b884a8ef7f6b0b Mon Sep 17 00:00:00 2001 From: Stefano Zacchiroli Date: Thu, 15 Apr 2004 12:25:40 +0000 Subject: [PATCH] added support for multiple dtd_base_urls --- helm/ocaml/getter/http_getter_common.ml | 52 +++++++++++++++---------- helm/ocaml/getter/http_getter_env.ml | 7 ++-- helm/ocaml/getter/http_getter_env.mli | 2 +- 3 files changed, 37 insertions(+), 24 deletions(-) diff --git a/helm/ocaml/getter/http_getter_common.ml b/helm/ocaml/getter/http_getter_common.ml index bbed79722..b1f96d8bd 100644 --- a/helm/ocaml/getter/http_getter_common.ml +++ b/helm/ocaml/getter/http_getter_common.ml @@ -75,38 +75,50 @@ let patch_xsl ?(via_http = true) () = let patch_entity ?(via_http = true) () = if via_http then fun line -> - Pcre.replace - ~pat:(sprintf "ENTITY (.*) SYSTEM\\s+\"(%s/)?" - (Lazy.force Http_getter_env.dtd_base_url)) - ~templ:(sprintf "ENTITY $1 SYSTEM \"%s/getdtd?uri=" - (Lazy.force Http_getter_env.my_own_url)) + List.fold_left + (fun url s -> + Pcre.replace + ~pat:(sprintf "ENTITY (.*) SYSTEM\\s+\"(%s/)?" url) + ~templ:(sprintf "ENTITY $1 SYSTEM \"%s/getdtd?uri=" + (Lazy.force Http_getter_env.my_own_url)) + s) line + (Lazy.force Http_getter_env.dtd_base_urls) else fun line -> - Pcre.replace - ~pat:(sprintf "ENTITY (.*) SYSTEM\\s+\"(%s/)?" - (Lazy.force Http_getter_env.dtd_base_url)) - ~templ:(sprintf "ENTITY $1 SYSTEM \"file://%s/" - (Lazy.force Http_getter_env.dtd_dir)) + List.fold_left + (fun url s -> + Pcre.replace + ~pat:(sprintf "ENTITY (.*) SYSTEM\\s+\"(%s/)?" url) + ~templ:(sprintf "ENTITY $1 SYSTEM \"file://%s/" + (Lazy.force Http_getter_env.dtd_dir)) + s) line + (Lazy.force Http_getter_env.dtd_base_urls) let patch_doctype ?(via_http = true) () = if via_http then fun line -> - Pcre.replace - ~pat:(sprintf "DOCTYPE (.*) SYSTEM\\s+\"%s/" - (Lazy.force Http_getter_env.dtd_base_url)) - ~templ:(sprintf "DOCTYPE $1 SYSTEM \"%s/getdtd?uri=" - (Lazy.force Http_getter_env.my_own_url)) + List.fold_left + (fun url s -> + Pcre.replace + ~pat:(sprintf "DOCTYPE (.*) SYSTEM\\s+\"%s/" url) + ~templ:(sprintf "DOCTYPE $1 SYSTEM \"%s/getdtd?uri=" + (Lazy.force Http_getter_env.my_own_url)) + s) line + (Lazy.force Http_getter_env.dtd_base_urls) else fun line -> - Pcre.replace - ~pat:(sprintf "DOCTYPE (.*) SYSTEM\\s+\"%s/" - (Lazy.force Http_getter_env.dtd_base_url)) - ~templ:(sprintf "DOCTYPE $1 SYSTEM \"file://%s/" - (Lazy.force Http_getter_env.dtd_dir)) + List.fold_left + (fun url s -> + Pcre.replace + ~pat:(sprintf "DOCTYPE (.*) SYSTEM\\s+\"%s/" url) + ~templ:(sprintf "DOCTYPE $1 SYSTEM \"file://%s/" + (Lazy.force Http_getter_env.my_own_url)) + s) line + (Lazy.force Http_getter_env.dtd_base_urls) let patch_dtd = patch_entity diff --git a/helm/ocaml/getter/http_getter_env.ml b/helm/ocaml/getter/http_getter_env.ml index 985faee9b..fa3216dcc 100644 --- a/helm/ocaml/getter/http_getter_env.ml +++ b/helm/ocaml/getter/http_getter_env.ml @@ -47,7 +47,8 @@ let cic_dir = lazy (Helm_registry.get "getter.cic_dir") let nuprl_dir = lazy (Helm_registry.get "getter.nuprl_dir") let rdf_dir = lazy (Helm_registry.get "getter.rdf_dir") let dtd_dir = lazy (Helm_registry.get "getter.dtd_dir") -let dtd_base_url = lazy (Helm_registry.get "getter.dtd_base_url") +let dtd_base_urls = lazy (Helm_registry.get_string_list + "getter.dtd_base_urls") let port = lazy (Helm_registry.get_int "getter.port") let _servers = ref None @@ -117,7 +118,7 @@ servers_file:\t%s host:\t\t%s port:\t\t%d my_own_url:\t%s -dtd_base_url:\t%s +dtd_base_urls:\t%s cache_mode:\t%s servers: \t%s @@ -128,7 +129,7 @@ servers: (Lazy.force nuprl_dir) (Lazy.force rdf_dir) (Lazy.force dtd_dir) (Lazy.force servers_file) (Lazy.force host) (Lazy.force port) (Lazy.force my_own_url) - (Lazy.force dtd_base_url) + (String.concat " " (Lazy.force dtd_base_urls)) (match Lazy.force cache_mode with | `Normal -> "Normal" | `Gzipped -> "GZipped") diff --git a/helm/ocaml/getter/http_getter_env.mli b/helm/ocaml/getter/http_getter_env.mli index f55867c92..d3bc7f319 100644 --- a/helm/ocaml/getter/http_getter_env.mli +++ b/helm/ocaml/getter/http_getter_env.mli @@ -47,7 +47,7 @@ val rdf_dir : string lazy_t (* RDFs' directory *) val dtd_dir : string lazy_t (* DTDs' root directory *) val servers_file : string lazy_t (* servers.txt file *) val port : int lazy_t (* port on which getter listens *) -val dtd_base_url : string lazy_t (* base URL for DTD downloading *) +val dtd_base_urls : string list lazy_t (* base URLs for document patching *) (* {2 derived data} *) -- 2.39.2