packages feed

HXQ-0.11.0: Test2.hs

{--------------------------------------------------------------
-
- Testing the  XQuery compiler on a large file
- Download dblp.xml from http://dblp.uni-trier.de/xml/
- Programmer: Leonidas Fegaras (fegaras@cse.uta.edu)
- Date: 07/24/2008
-
---------------------------------------------------------------}

{-# LANGUAGE TemplateHaskell #-}

module Main where

import Text.XML.HXQ.XQuery


f(x,y) = $(xe "<a>{$x,$y}</a>")


main = do a <- $(xq ("<result>{                                                               "
                 ++"     for $x at $i in doc('data/dblp.xml')//inproceedings                  "
                 ++"     where $x/author = 'Leonidas Fegaras'                                 "
                 ++"     order by $x/year descending                                          "
                 ++"     return <paper>{ $i, $x/booktitle/text(),                             "
                 ++"                     ':', $x/title/text()                                 "
                 ++"            }</paper>                                                     "
                 ++"  }</result>                                                              "))
          putXSeq a
          b <- $(xq "f($a/paper[10],$a/paper[8])")
          putXSeq b