[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Alain Frisch <alain@f...> |
| Subject: | Re: [Caml-list] xpath or alternatives |
Richard Jones wrote:
> let devs = {{ map [xml] with
> | <domain..>[<devices..>[<disk..>[<source dev=(Latin1 & s) ..>_]]]
> | <domain..>[<devices..>[<disk..>[<source file=(Latin1 & s) ..>_]]] -> [s]
> | _ -> [] }} in
The following should work:
let l = {{ [xml] }} in
let l = {{ map l with <domain..>l -> l | _ -> [] }} in
let l = {{ map l with <devices..>l -> l | _ -> [] }} in
let l = {{ map l with <disk..>l -> l | _ -> [] }} in
let l = {{ map l with <source dev=(Latin1 & s) ..>_
| <source file=(Latin1 & s) ..>_-> s
| _ -> [] }} in
...
let () =
let l = {{ [xml] }} in
let l = {{ (((l.(<domain..>_)) / .(<devices..>_)) / .(<disk..>_)) / }} in
let l = {{ map l with <source dev=(Latin1 & s) ..>_
| <source file=(Latin1 & s) ..>_ -> s
| _ -> [] }} in
..
This uses the constructions e/ and e.(t) as described in the manual.
That said, using OCamlDuce for this kind of XML data-extraction seems
just crazy to me.
Cheers,
Alain