Nethtml => cgi#output_string

"Rakotomandimby (R12y) Mihamina" <[email protected]> Thu, 19 May 2005 01:19:33 +0200
Newsgroups gmane.comp.lang.ocaml.lib.net.devel
Message-ID <1116458373.7658.123.camel@ngeza>
Hi,

I encounter a big problem mainly because I am new to Ocaml.
Well.

When using Nethtml to built a web page, its documentation shows hoe to
write a Nethtml.Element to a file.

I use Netcgi on the other side, and output_string only takes a string as
argument.

Before committing the work, I have to submit all the Nethtml.Element to
output_string. 

I can always play the fool and:

- Write to a file using Nethtml.write (then close it)
- Read the file line by line and give each line to output_string

But that would be very dumb, I guess...
Someone, on a French speaking Newsgroup adviced me this:

# let page = Nethtml.Element ( "body" , [] , [Nethtml.Data ("rien")]);; 
val page : Nethtml.document =
  Nethtml.Element ("body", [], [Nethtml.Data "rien"])

That would create an Element (dont care its conformity first, it's just
for test)

Then to directly give it to output_string:

let cgi = 
    new std_activation ~operating_type:buffered_transactional_optype ()
in
cgi # set_header;
Nethtml.write 
    (cgi#output#output_string :> Netchannels.out_obj_channel) [page];
cgi # output # commit_work();;



It's ugly. Is it, at least, correct? I ask because I did not learn
objects yet in Ocaml and I will blindly apply till I know what I do, so
that I need advice before doing anything...

Thank you for all.


-- 
ASPO Infogérance       http://aspo.rktmb.org/activites/infogerance
Unofficial FAQ fcolc   http://faq.fcolc.eu.org/
LUG sur Orléans et alentours (France).
Tél : 02 34 08 26 04 / 06 33 26 13 14



-------------------------------------------------------
This SF.Net email is sponsored by Oracle Space Sweepstakes
Want to be the first software developer in space?
Enter now for the Oracle Space Sweepstakes!
http://ads.osdn.com/?ad_idt12&alloc_id344&op=click