From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id TAA25658; Sun, 29 Feb 2004 19:13:08 +0100 (MET) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id TAA26082 for ; Sun, 29 Feb 2004 19:13:07 +0100 (MET) Received: from mwinf0202.wanadoo.fr (smtp2.wanadoo.fr [193.252.22.29]) by nez-perce.inria.fr (8.12.10/8.12.10) with ESMTP id i1TIDDIq021049 for ; Sun, 29 Feb 2004 19:13:13 +0100 Received: from PWARP (ABordeaux-103-1-14-189.w81-48.abo.wanadoo.fr [81.48.84.189]) by mwinf0202.wanadoo.fr (SMTP Server) with SMTP id CF6DEA400389; Sun, 29 Feb 2004 19:13:05 +0100 (CET) Message-ID: <001601c3feef$acb30c80$0100a8c0@PWARP> From: "Nicolas Cannasse" To: "David MENTRE" Cc: "OCaml" References: <87y8qnnwsm.fsf@linux-france.org><008301c3fe0f$0b410180$ef01a8c0@warp> <871xodlqx3.fsf@linux-france.org> Subject: Re: [Caml-list] Looking for OCaml code to load & save XML files Date: Sun, 29 Feb 2004 19:13:03 +0100 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 X-Miltered: at nez-perce by Joe's j-chkmail ("http://j-chkmail.ensmp.fr")! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; cannasse:01 warplayer:01 caml-list:01 pxp:01 motion-twin:01 conciseness:01 dependencies:01 pleases:01 hash:01 gerd's:01 minimise:01 dependencies:01 add-on:01 extlib:01 camlzip:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk > > My advice : first experiment XmlLight and then switch to PXP if you lack > > features. > > > > http://tech.motion-twin.com/xmllight > > I like you advice. I've looked at your library and it's conciseness and > lack of dependencies pleases me. > > BTW, I need to save some short binary data in the XML format (e.g. MD5 > 128bits hash). Therefore, I would like to transform from/to an OCaml > binary string type into a string suitable for printing in an XML file > (in a CDATA field). Which code would you recommend to do that the "XML > way"? At first sight, I intend to use Gerd's code to encode/decode MIME > and base64 strings. If your goal is to minimise dependencies, just writing some lines of B64 encode/decode is a good idea (btw, this could be a good add-on for ExtLib : http://ocaml-lib.sf.net ). > As another side note, I also intend to read and write gziped XML files, > using Xavier's camlzip package. As your module uses Lexing.from_* to get > input file, I'll probably add an SFunction source type to be able to use > Lexing.from_function. In the same way, I'll probably modify your output > functions (Xml.to_string) to be able to ouput into a Gzip.out_channel > without producing the whole XML file in a string. > > I'll gladly accept any advice on how to use your code, I think you don't need any special advice in order to add the SFunction to XmlLight, it looks easy. For gzip, XmlLight has 2 printers : Xml.to_string for "compact" mode (without any line returns or indentation) and Xml.to_string_fmt for "formatted" mode (a lot more user-readable). Writing a custom "compact" printer which directly output the data into a Gzip.out_channel is also something easy to do (look at to_string in xml.ml for example). Another way is to add an event-driven printer that would be able to output on any underlying data structure. If you need this, don't hesitate to ask and I will add this to XmlLight. You can contact me again if you have any question. Regards, Nicolas Cannasse ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners