{-------------------------------------------------------------- - - The main program of the XQuery processor - Programmer: Leonidas Fegaras (fegaras@cse.uta.edu) - Date: 03/19/2008 - ---------------------------------------------------------------} {-# OPTIONS_GHC -fth #-} module Main where import XQuery f(d,s) = $(xe "{$s//firstname/text(),' ',$s//lastname/text()}") main = do a <- $(xq (" for $s in doc('data/cs.xml')//gradstudent " ++" orderby $s/gpa descending, $s//lastname " ++" return {$s//firstname/text(),' ', " ++" $s//lastname/text(),' ', " ++" $s/gpa/text()} ")) putStrLn (show a) let query name = $(xq " doc('data/cs.xml')//gradstudent[.//lastname = $name]//firstname ") b <- query $(xe " 'Galanis' ") -- or use: query [XText "Galanis"] putStrLn (show b) c <- $(xq (" { " ++" let $d := doc('data/cs.xml') " ++" for $s in $d//gradstudent " ++" where $s/gpa = '4.0' " ++" return f($d//deptname,$s) " ++" } ")) putStrLn (show c)