|
From: | Serge Leblanc |
Subject: | [Demexp-dev] Re: Use of CDuce |
Date: | Thu, 14 Oct 2004 14:30:43 +0200 |
While I'm at asking question, I have a batch of others: My main issue is to avoid converting the whole XML file into an OCaml representation and then convert this representation into the demexp data structures. Does CDuce help in this?
BTW, I also noticed that CDuce relies on PXP. There is no license issue with PXP (it is already in debian, package libpxp-ocaml-dev) so we could fall back on PXP to read/write XML, maybe at the cost of usability compared to CDuce.
I'm still pondering the advantages and inconvenients of all this XML machinery. I still fear to much complexity for rather simple needs (convert XML to demexp ocaml structures and vice versa).
<?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 kind="individual"> <login>david</login> <password>md5pass</password> <group>admin</group> <group>demexp</group> </participant> <participant kind="individual"> <login>felix</login> <password>md5pass</password> <group>abmin</group> <group>demexp</group> </participant> <participant kind="delegate"> <login>frederic</login> <password>md5pass</password> <group>abmin</group> <group>demexp</group> </participant> </participant_base> </demexp_base>Le fichier .mli permet de préciser pour Ocaml la signature des fonctions CDuce. Ici la fonction load_demexp prend en argument le nom du fichier xml et retournant la liste des utilisateurs individual.
(* demexp.mli *) val load_demexp: string -> string list
(* demexp.cd *) let load_demexp (f : Latin1) : [ Latin1* ] = let d = load_xml f in map [d]/<participant_base>_/<participant kind="individual">_/<login>Latin1 with <login>s -> s ;;
# [d]/<participant_base>_/<participant kind="individual">_/<login>Latin1 ;;permet de récupérer tous les élément de type <login>Latin1 dont le parent est <participant kind="individual">. Cela donne la liste [ <login>[ 'root' ] <login>[ 'david' ] <login>[ 'felix' ] ] ayant comme type [ <login>Latin1* ].
- : [ <login>Latin1* ] = [ <login>[ 'root' ] <login>[ 'david' ] <login>[ 'felix' ] ]
map [d]/<participant_base>_/<participant kind="individual">_/<login>Latin1 with <login>s -> s ;;- : [ Latin1* ] = [ "root" "david" "felix" ]
(* demexp_program.ml *) let t = Demexp.load_demexp "demexp_base.xml" in List.map (Format.printf "@[%s@ %s @]" "individual:") t ;;
-- pub 1024D/73791C2B 2002-09-30 Serge Leblanc <address@hidden> Primary key fingerprint: 8E0C 0D6D E026 A278 9278 BF4F 1A93 D552 7379 1C2B |
demexp_base.xml
Description: Text Data
demexp_build.sh
Description: application/shellscript
demexp.cd
Description: Text document
demexp.mli
Description: Text document
demexp_program.ml
Description: Text document
signature.asc
Description: This is a digitally signed message part
[Prev in Thread] | Current Thread | [Next in Thread] |