[cduce-users] issues about queries
Cédric Miachon
Cedric.Miachon at lri.fr
Thu May 11 09:34:26 CEST 2006
Hi,
> Hi, my name is Pierluigi and I'm actually using cduce for my final stage.
> I made a program to take the list of all the authors, but I found some
> problems.
> Here the structure of my types:
>
> type uricloud = <uricloud>[ nodelist edgelist ]
> type nodelist = <nodelist>[ node* ]
> type node = <node id=String name=String>[ properties types ]
> type edgelist = <edgelist>[ edge* ]
> type edge = <edge id=String target=String source=String>[ properties types
> ]
> type properties = <properties>[ property* ]
> type property = <property name=String>[ PCDATA]
> type types = <types>[ type+ ]
> type type = <type>[ PCDATA]
I don't see where is the type corresponding to the authors?
e.g. in http://www.cduce.org/tutorial_queries.html
we have the types :
type book = <book year=String>[title (author+ | editor+ ) publisher price ]
type author = <author>[last first ]
...
>
> (* take the <type> fields of a node, which state if a node is an
> author or whatelse *)
> let tipi (x : node) : [String*] =
> map [x]/types/type with <type ..>t -> t
>
This function is useless in CDuce
if x is a node, then the expression [x]/types/type returns always a
sequence of type "type". If you want the string of "type" you can write :
[x]/types/type/_ or [x]/types/type/Char
then :
let tipi (x : node) : [String*] =
[x]/types/type/Char
> (* Check the type fields to state if a node is an author *)
> let isAuthor (x : [String*]) : Bool = not((select aa
> from aa in x
> where aa = author) = [])
>
I don't understand the where expression : where aa = author
If x is a sequence of String, so aa is a String, so the where expression
should be : where aa = "author" (with quotation marks on author)
> Now I would like to take the list of all the authors; this is my best
> attempt, that doesn't work
>
> let findAuthors (x : uricloud) : [node*] = select c
> from c in [x]/<nodelist>_/<node ..>_
> where (( tipi(isAuthor c)) = 'true )
>
1) the atom types in CDuce begin with a backquote ` and not a simple quote
'. thus here it's `true
2) where (( tipi(isAuthor c)) = 'true ) is equivalent to where (
tipi(isAuthor c))
3) the expression [x]/<nodelist>_/<node ..>_ returns a sequence of node,
so c is a node.
The expression isAuthor c needs a sequence of String, however c is a node.
I think it's: where isAuthor (tipi c))
--
Cedric
More information about the Cduce-users
mailing list