[Ocaml-pxp-users] Help needed with PXP api

Gerd Stolpmann gerd at gerd-stolpmann.de
Tue Mar 8 09:43:33 PST 2005


Am Dienstag, den 08.03.2005, 15:31 +0100 schrieb Alain Frisch:
> Hello,
> 
> Gerd, thanks a lot for the detailled answer. In order to avoid dealing 
> with Neturl (because the application has its own Url library), I cooked 
> this simple resolver:
> 
> let channel_of_id rid =
>    let url =
>      match rid.rid_system_base, rid.rid_system with
>        | Some base, Some rel when not (Url.is_url 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 resolver = new resolve_to_any_obj_channel ~channel_of_id ()
> 
> 
> and I simply use the source XExtID (System uri,None,resolver).
> 
> 
> Url.load_url is my magic function. Url.is_url checks whether a string 
> starts with a URL schema. Url.local apply a relative URL to a base URL 
> (it also works with file names).
> 
> Do you see anything wrong with this resolver ?

It looks good. I think even the resolution of relative URLs works as
expected.

Perhaps a small glitch: open_in_bin url. This is not fully correct
because URLs may contain escaped characters (%-notation)

Gerd
-- 
------------------------------------------------------------
Gerd Stolpmann * Viktoriastr. 45 * 64293 Darmstadt * Germany 
gerd at gerd-stolpmann.de          http://www.gerd-stolpmann.de
------------------------------------------------------------





More information about the Ocaml-pxp-users mailing list