|
From: Peter J. <pe...@jo...> - 2006-07-30 13:25:08
|
A recent project required me to parse gzipped XML files using Xml-Light.
The most convenient way to access the gzipped files was using Extlib's
Unzip.inflate on an IO.input stream. However, since Xml-Light does not
support IO or the standard OO file interface (it only supports input
from files, Pervasives streams, strings, and lexbufs), it was necessary
to define a wrapper function:
let lexbuf_of_input i =
Lexing.from_function
(fun s n ->
try
IO.input i s 0 n
with IO.No_more_input ->
0);;
I just wonder whether it might be worth adding a couple of conversion
functions along these lines to the IO module, since I can imagine them
being generally useful? The code is trivial, but one of the things I
value Extlib for is that it reduces the need for boilerplate like this.
|