Commit 3cd84884 authored by Pietro Abate's avatar Pietro Abate
Browse files

[r2003-11-27 15:18:45 by cmiachon] a new query

Original author: cmiachon
Date: 2003-11-27 15:18:45+00:00
parent 0e75d1c3
include "tests/cql/doc.cd";;
(* tri a bulle *)
let fun passe ([Any*] -> [Any*])
[]->[]
| [a] -> [a]
| [a b;c] -> if a << b then [a] @ passe ( [b] @ c)
else [b] @ passe ( [a] @ c) ;;
let fun order ([Any*] -> [Any*])
l -> let l2=passe(l) in
if l = l2 then l
else order(l2);;
mmh not recursive terminal?
(**********************
List the titles and years of all books published by Addison-Wesley after 1991, in alphabetic order.
**********************)
(****************
In XQUERY
<bib>
{
for $b in doc("http://www.bn.com/bib.xml")//book
where $b/publisher = "Addison-Wesley" and $b/@year > 1991
order by $b/title
return
<book>
{ $b/@year }
{ $b/title }
</book>
}
</bib>
*************************)
let q7p=
let q=order (
select <book year=year>[t]
from <bib>[b::Book*] in [doc],
<book year=year>[t&Title _* <publisher>['Addison-Wesley'] ;_ ] in b
where int_of(year) >> 1991
) in <bib>q ;;
(* here year attribute is set as String (see include "tests/cql/doc.cd")
so we needs use Where clause
otherwise we can use <book year=1991--*>[...] *)
let q7x =
let q = order (
select <book year=y>([b]/<title>_)
from b in [doc]/<book>[ _* <publisher>['Addison-Wesley'];_],
y in [doc]/@year
where int_of(y) >> 1991
) in <bib>q;;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment