[database-support] How to interact with the eXist XML database

Hi everyone,

I intent to build a small application for evaluation purpose involving
the eXist database. The goal is to analyse different data storing
paradigms (relational, tree-based (XML), graph-based (RDF), ...) in
the context of an XML application.

Thus, I need to find a way to query the eXist database from the Rails
application. I've RESTful queries coming to the application which must
serves the relevant XML documents (or updates, creates or deletes
them) and non-RESTful, application specific queries that will extract
some specific, nodes-level information and serves them as JSON.

I already built a table-based application using MySQL and I'm now
facing the task of doing the same using eXist.

My idea is to forward the RESTful queries directly to the eXist
server, while the non-RESTful ones are re-written in the application
to query XQueries stored in eXist in a RESTful fashion. Unfortunately,
as I'm unfamiliar with the Ruby on Rails framework, I'm currently
stuck at this point.

More specifically, I have the following possible requests:

1. GET /<resources> -> returns a HTML page listing all resources
2a. GET /<resources>/<id>(.xhtml)(/edit) -> returns an HTML page
containing a JS library to allow the XML data display or edition
2b. GET /<resources>/<id>.xml(/edit) -> returns the XML data (to edit
or to show)
3. POST /<resources> -> creates a new resource with the provided XML
data (in the POST body)
4. DELETE /<resources>/<id> -> deletes the resource

5. GET /services/<servicename>/<resources>?<query> -> perform the
"servicename" service on the selected resource, given the query
parameters.

Requests 1 and 2a are already ok (they aren't changing from my former
application using MySQL). Technically, I need:

- to redirect/map requests 2b, 3, 4 to the eXist database.
- to directly perform XQueries for requests 5 or to invoke a pre-
written XQuery stored on the eXist server.

Has someone an idea on how to achieve this?

Thanks by advance for anyone helping me :slight_smile:

Antoine