HXQ-0.8: A Compiler from XQuery to Haskell




HXQ is a fast and space-efficient compiler from XQuery (the standard query language for XML) to embedded Haskell code. The translation is based on Haskell templates. It also provides an interpreter for evaluating ad-hoc XQueries read from input or from files. For more information, look at http://lambda.uta.edu/HXQ/.


The XML Data Representation

data XTree Source

Rose tree representation of XML data. The Int in XElem is the preorder numbering used for the document order of nodes.


XElem !Tag !AttList !Int [XTree]

an XML tree node (element)

XText !String

an XML tree leaf (PCDATA)

XInt !Int

an XML tree leaf (int)

XFloat !Float

an XML tree leaf (float)

XBool !Bool

an XML tree leaf (boolean)

XPI Tag String

processing instruction

XGERef Tag

general entity reference

XComment String


XError String

error report


type XSeq = [XTree]Source

type AttList = [(Name, String)]Source

putXSeq :: XSeq -> IO ()Source

Print the XQuery result (which is a sequence of XML fragments) with no waiting

The XQuery Compiler

xq :: String -> Q ExpSource

Run an XQuery that reads XML documents. When evaluated, it returns IO XSeq.

xe :: String -> Q ExpSource

Run an XQuery expression that does not read XML documents. When evaluated, it returns XSeq.

The XQuery Interpreter

xquery :: String -> IO XSeqSource

Evaluate the XQuery using interpreter.

xfile :: String -> IO XSeqSource

Read an XQuery fom a file and run it using the interpreter.