caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Till Varoquaux <till@pps.jussieu.fr>
To: Richard Jones <rich@annexia.org>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] xpath or alternatives
Date: Wed, 30 Sep 2009 10:28:14 -0400	[thread overview]
Message-ID: <9d3ec8300909300728t6edb78e3w447fa06358942edf@mail.gmail.com> (raw)
In-Reply-To: <20090930140107.GB5126@annexia.org>

If I am not mistaken you are selecting a domain whose first child is a
device node whose only child is disk node ...

instead of:
<domain..>[<devices..>[<disk..>[<source dev=(Latin1 & s) ..>_]]]

you should aim for something in the vein of:

<domain ..>  [_* (<devices..> (<disk..>(<source dev=(Latin1 & s)>|
<souce file = (Latin1 &s)>_)* |_)* _*]

Till



On Wed, Sep 30, 2009 at 10:01 AM, Richard Jones <rich@annexia.org> wrote:
> On Wed, Sep 30, 2009 at 09:33:07AM -0400, Till Varoquaux wrote:
>> OCamlduce (Alain correct me if I am wrong) basically maintains two
>> separate type systems side by side (the Xduce one and the Ocaml one).
>> This is done in order to make Ocamlduce maintainable by keeping a
>> clear separation. As a result you have to explicitly convert values
>> between type systems using {:...:}. These casts are type safe but do
>> lead to some work at runtime.
>>
>> Also note that ocaml's string are Latin1 and not String in the XML world. So:
>>
>>  let devs = match xml with
>>    | {{ <domain>[<devices>[<source dev=(Latin1 & dev) ..>[]]] }} -> {:dev:}
>>    | {{ <domain>[<devices>[<source file=(Latin1 & file) ..>[]]] }} ->
>> {:file:} in
>>
>> Should work (I'm rusty and have nothing to check handy).
>
> I tried variations on the above, but couldn't get it to work.
> ocamlduce is very fond of a mysterious error called "Error: Subtyping
> failed", which is very difficult for me to understand, and therefore
> must be absolutely impossible for someone not used to strong typing.
>
> This is where I'm heading at the moment (sorry, my previous
> example missed a <disk> level inside <devices>), so:
>
>  let xml = from_string xml in
>  prerr_endline (Ocamlduce.to_string xml);
>
>  let devs = {{ map [xml] with
>    | <domain..>[<devices..>[<disk..>[<source dev=(Latin1 & s) ..>_]]]
>    | <domain..>[<devices..>[<disk..>[<source file=(Latin1 & s) ..>_]]] -> [s]
>    | _ -> [] }} in
>  prerr_endline (Ocamlduce.to_string devs);
>
> +1 : this compiles
> -1 : it doesn't work, devs is empty
>
> This is what the first prerr_endline prints:
>
> <domain
>  type="kvm"
>  id="2">[
>  <name>[ 'CentOS5x32' ]
>  <uuid>[ '2ce397d9-1931-feb1-8ad8-15f22c4f18af' ]
>  <memory>[ '524288' ]
>  <currentMemory>[ '524288' ]
>  <vcpu>[ '1' ]
>  <os>[ <type arch="x86_64" machine="pc-0.11">[ 'hvm' ] <boot dev="hd">[ ] ]
>  <features>[ <acpi>[ ] <apic>[ ] <pae>[ ] ]
>  <clock offset="utc">[ ]
>  <on_poweroff>[ 'destroy' ]
>  <on_reboot>[ 'restart' ]
>  <on_crash>[ 'restart' ]
>  <devices>[
>    <emulator>[ '/usr/bin/qemu-kvm' ]
>    <disk
>      type="block"
>      device="disk">[
>      <source dev="/dev/vg_trick/CentOS5x32">[ ]
>      <target bus="ide" dev="hda">[ ]
>      ]
>    <interface
>      type="network">[
>      <mac address="54:52:00:3c:76:11">[ ]
>      <source network="default">[ ]
>      <target dev="vnet0">[ ]
>      ]
>    <serial type="pty">[ <source path="/dev/pts/7">[ ] <target port="0">[ ] ]
>    <console
>      type="pty"
>      tty="/dev/pts/7">[
>      <source path="/dev/pts/7">[ ]
>      <target port="0">[ ]
>      ]
>    <input type="mouse" bus="ps2">[ ]
>    <graphics autoport="yes" port="5900" type="vnc">[ ]
>    <video>[ <model type="cirrus" vram="9216" heads="1">[ ] ]
>    ]
>  ]
>
> and what the second prerr_endline prints:
>
> ""
>
> Rich.
>
> --
> Richard Jones
> Red Hat
>
> _______________________________________________
> Caml-list mailing list. Subscription management:
> http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
> Archives: http://caml.inria.fr
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs
>


  reply	other threads:[~2009-09-30 14:28 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-09-28 12:17 Richard Jones
2009-09-28 12:48 ` [Caml-list] " Yaron Minsky
2009-09-28 15:06   ` Till Varoquaux
2009-09-29 23:00     ` Mikkel Fahnøe Jørgensen
2009-09-30 10:16       ` Richard Jones
2009-09-30 10:36         ` Sebastien Mondet
2009-09-30 10:49         ` Mikkel Fahnøe Jørgensen
2009-09-30 11:05         ` Dario Teixeira
2009-09-30 11:57           ` Richard Jones
2009-09-30 12:59             ` Richard Jones
2009-09-30 13:33               ` Till Varoquaux
2009-09-30 14:01                 ` Richard Jones
2009-09-30 14:28                   ` Till Varoquaux [this message]
2009-09-30 14:51                   ` Alain Frisch
2009-09-30 15:09                     ` Richard Jones
2009-09-30 15:18                       ` Alain Frisch
2009-10-28  2:22         ` Daniel Bünzli
2009-09-30 13:39 ` Stefano Zacchiroli
2009-09-30 14:49   ` Gerd Stolpmann
2009-09-30 15:12     ` Stefano Zacchiroli
2009-09-30 15:22       ` Jordan Schatz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9d3ec8300909300728t6edb78e3w447fa06358942edf@mail.gmail.com \
    --to=till@pps.jussieu.fr \
    --cc=caml-list@inria.fr \
    --cc=rich@annexia.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).