xHeimdall
xHeimdall is an implementation of Heimdall in the XQuery programming language.
See also
There is another implementation of HEIMDALL for the Python programming language:: pyHeimdall.
Install
Note
There is only support for BaseX. If you have another XQuery implementation in mind, feel free to contribute.
If you have BaseX installed, inside the user interface, you can install the package like this:
REPO INSTALL https://datasphere.gitpages.huma-num.fr/heimdall/xquery/heimdall.xar
If BaseX complains “[repo:not-found] Package ... heimdall.xar not found.”, you can temporarily set IGNORECERT=true in your BaseX configuration file and retry.
As an alternative, you can manually download the package and then install it using its local path. Using the command like interface, it can work like this:
curl -k https://datasphere.gitpages.huma-num.fr/heimdall/xquery/heimdall.xar --output heimdall.xar
basex -c"<repo-install path='heimdall.xar'/>"
Quickstart
Note
These code snippets apply to Heimdall version 3 and greater.
For version 2, just replace:
heimdall:getDatabasebyheimdall:getDatabaseItems,heimdall:createDatabasebyheimdall.serialize.
To retrieve the contents of a database in format format from location url, just use the heimdall:getDatabase function:
heimdall:getDatabase(map {
'url': url,
'format': format
})
To export a database contents $tree to the format format, use the heimdall:createDatabase function:
heimdall:createDatabase($items, map {
'format': format
})
For example, the following codes imports a MySQL database, then exports it as CSV:
let $tree := heimdall:getDatabase(map {
'url': 'mysql://localhost',
'database': 'your_db_name_here',
'format': 'sql:mysql'
})
return
heimdall:createDatabase($tree, map {
'format': 'csv'
})
Wanna learn more?
To discover xHeimdall features, you can read the reference manual (in french).