demexp-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Demexp-dev] CDuce binding in Makefile.


From: Serge Leblanc
Subject: Re: [Demexp-dev] CDuce binding in Makefile.
Date: Mon, 11 Oct 2004 13:27:59 +0200

On Sun, 2004-10-10 at 19:27, David MENTRE wrote:
Serge,

Serge Leblanc <address@hidden> writes:

> CDuce was precisely built to handle XML import and export with safety
> and efficiency since OCaml, look at :
> http://www.cduce.org/manual_interfacewithocaml.html
>
> "Use CDuce as an XML layer (input/output/transformation) for OCaml
> projects;"
>
> The code which CDuce produces can be directly linked with OCaml. 

Ok, I think I'm starting to understand. So we could use CDuce to
generate a OCaml code that would allow to read/write the XML specific to
OCaml. Right?

Yes, that's right.

If true, I have several remarks:

 1. there is no need to include CDuce into demexp source. We could just
    add it as an external requirements, like ocaml RPC package for
    example.

That will be well the case. CDuce is also a compiler which from a source .cd file to build a .cmo or .cmx files.

 2. could you show us (on this list) a simple example of ocaml code
    produced by CDuce and how we would use it in demexp? No need to
    start from a real DTD, you could use a dummy example able to parse
    following xml:

<?xml version="1.0" ?>

<demexp_base version="1.0">

  <participant_base>
    <participant kind="individual"> <!-- or "delegate" -->
      <login>root</login>
      <password>md5pass</password>
      <group>admin</group>
      <group>demexp</group>
    </participant>

  </participant_base>

</demexp_base>
(* demexp.mli *)
val load_demexp: string -> Cduce_lib.Value.t


(* demexp.cd *)
let load_demexp (f : Latin1) : Any = load_xml f ;;


(* demexp_program.ml *)
let t = Demexp.load_demexp "demexp_base.xml" in
  Cduce_lib.Value.dump_xml Format.std_formatter t ;;


ocamlfind ocamlopt -c demexp.mli -I $(ocamlfind query cduce)
cduce --compile demexp.cd -I $(ocamlfind query cduce)
ocamlfind ocamlopt -c -package cduce -pp "cdo2ml -static" -impl demexp.cdo
ocamlfind ocamlopt -o demexp -package cduce -linkpkg  demexp.cmx demexp_program.ml -I ./

This example isn't significant and doesn't profit from CDuce type-safe paradigm.
Here an better example with a type control and a filter optimized by CDuce.

(* demexp.mli *)
val load_demexp: string -> string list

(* demexp.cd *)
let load_demexp (f : Latin1) : [ String* ] =
    let  d = load_xml "demexp_base.xml" in
        map [d]/<participant_base>_/<participant kind="individual">_/<login>String  with
            <login>s -> s
  ;;

(* demexp_program.ml *)
let t = Demexp.load_demexp "demexp_base.xml" in
  Cduce_lib.Value.dump_xml Format.std_formatter t ;;

(* demexp_program.ml *)
let t = Demexp.load_demexp "demexp_base.xml" in
  List.map (Format.printf "@[%s@ address@hidden" "individual:") t ;;

[Here I express myself in French so that my thinking is well understood.]

Ces filtres utilisent les optimisations réalisées et inventées par l'équipe Cduce. Cela est important car toutes les autres méthodes reposant sur un fichier à plat (like: minimal XML from lablgtk2) ne supporteront, pas à terme, la charge des 5 milliards d'utilisateurs. Vous obligeant à implémenter des techniques de base de données qui sont déjà présentes dans CDuce.


 3. looking at http://www.cduce.org/manual_interfacewithocaml.html#link
    it says that CDuce compile code to bytecode. Demexp is currently
    using native code so I would like to be sure that native code can be
    used.

In the same paragraph documentation says :
"Everything works mutatis mutandis with the native OCaml compiler ocamlopt."


Yours,
d.
--
pub  1024D/73791C2B 2002-09-30 Serge Leblanc <address@hidden>
 Primary key fingerprint: 8E0C 0D6D E026 A278 9278  BF4F 1A93 D552 7379 1C2B

Attachment: signature.asc
Description: This is a digitally signed message part


reply via email to

[Prev in Thread] Current Thread [Next in Thread]