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 and database connectivity using HDBC. For more information, look at http://lambda.uta.edu/HXQ/.
- data XTree
- type XSeq = [XTree]
- type Tag = String
- type AttList = [(Name, String)]
- putXSeq :: XSeq -> IO ()
- xq :: String -> Q Exp
- xe :: String -> Q Exp
- xquery :: String -> IO XSeq
- xfile :: String -> IO XSeq
- xqdb :: String -> Q Exp
- connect :: FilePath -> IO Connection
- disconnect :: IConnection conn => conn -> IO ()
- prepareSQL :: IConnection conn => conn -> String -> IO Statement
- executeSQL :: Statement -> XSeq -> IO XSeq
- xqueryDB :: IConnection conn => String -> conn -> IO XSeq
- xfileDB :: IConnection conn => String -> conn -> IO XSeq
- shred :: IConnection conn => conn -> String -> String -> IO ()
- createIndex :: IConnection conn => conn -> String -> String -> IO ()
The XML Data Representation
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)
an XML tree leaf (PCDATA)
an XML tree leaf (int)
an XML tree leaf (float)
an XML tree leaf (boolean)
|XPI Tag String|
general entity reference
used internally to wrap an SQL statement
marker for no padding in XSeq
Print the XQuery result (which is a sequence of XML fragments) without buffering.
The XQuery Compiler
Run an XQuery that reads XML documents. When evaluated, it returns IO XSeq.
Run an XQuery expression that does not read XML documents. When evaluated, it returns XSeq.
The XQuery Interpreter
The XQuery Compiler with Database Connectivity
Run an XQuery that reads XML documents and queries databases. When evaluated, it returns (IConnection conn) => conn -> IO XSeq.
Connect to the relational database in filepath using the HDBC Sqlite3 driver
Disconnect from the remote database.
You do not need to explicitly close an IConnection object, but you may do so if
you so desire. If you don't, the object will disconnect from the database
in a sane way when it is garbage-collected. However, a disconnection may
raise an error, so you are encouraged to explicitly call
garbage collection may not run when the program terminates, and some databases
really like an explicit disconnect.
So, bottom line is, you're best off calling
disconnect directly, but the
world won't end if you forget.
This function discards any data not committed already. Database driver
implementators should explicitly call
rollback if their databases don't
do this automatically on disconnect.
Bad Things (TM) could happen if you call this while you have
active. In more precise language, the results in such situations are undefined
and vary by database. So don't do it.
The XQuery Interpreter with Database Connectivity
Evaluate the XQuery with database connectivity using the interpreter.
Read an XQuery with database connectivity from a file and run it using the interpreter.
Shredding and Publishing XML Documents Using a Relational Database
Store an XML document into the database under the given name.