Version française
Home     About     Download     Resources     Contact us    
Browse thread
xpath or alternatives
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ 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:
> On the other hand, the code is hard to understand.  It's not clear to
> me what the .(  ) syntax means, nor why there is an apparently trailing
> / character.

 From the manual:

If the x-expression e evaluates to an x-sequence, the construction e/ 
will result in a new x-sequence obtained by taking in order all the 
children of the XML elements from the sequence e. For instance, the 
x-expression [<a>[ 1 2 3 ] 4 5 <b>[ 6 7 8 ] ]/ evaluates to the x-value 
[ 1 2 3 6 7 8 ].

If the x-expression e evaluates to an x-sequence, the construction e.(t) 
(where t is an x-type) will result in a new x-sequence obtained by 
filtering e to keep only the elements of type t. For instance, the 
x-expression [<a>[ 1 2 3 ] 4 5 <b>[ 6 7 8 ] ].(Int) evaluates to the 
x-value [ 4 5 ].

> I have some comments:
> 
> (A) "Subtyping failed" is a very common error, but is only mentioned
> briefly in the manual.  I have no idea what these errors mean, so they
> should have more explanation.  Here is a simple one which was caused
> by me using a value instead of a list (but that is not at all obvious
> from the error message):
> 
>   Error: Subtyping failed Latin1 <= [ Latin1* ]
>   Sample:
>   [ Latin1Char ]

The error tells you that Latin1 is not a subtype of [ Latin1* ].
It probably means that you are trying to use a value of type Latin1 
where a value of type [ Latin1* ] is expected.

> (B) I think the interfacing code here:
> 
>   http://yquem.inria.fr/~frisch/ocamlcduce/samples/expat/
>   http://yquem.inria.fr/~frisch/ocamlcduce/samples/pxp/
>   http://yquem.inria.fr/~frisch/ocamlcduce/samples/xmllight/
> 
> should be distributed along with ocamlduce.

There was a GODI package that includes them. It would be ok to put these 
files in the distribution without compiling them (otherwise it would 
create a dependency on more OCaml packages). It's up to Stéphane Glondu, 
the new maintainer of OCamlDuce.


Cheers,

Alain