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

**URL:** <https://www.ruby-forum.com/t/database-support-how-to-interact-with-the-exist-xml-database/192089>\
**Category:** Rails\
**Created:** [July 23, 2010, 4:13pm UTC](https://www.ruby-forum.com/t/database-support-how-to-interact-with-the-exist-xml-database/192089 "2010-07-23T16:13:08Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Antoine](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/7ab992/32.png) [@Antoine](https://www.ruby-forum.com/u/Antoine)\
**Post date:** [July 23, 2010, 4:13pm UTC](https://www.ruby-forum.com/t/database-support-how-to-interact-with-the-exist-xml-database/192089/1 "2010-07-23T16:13:08Z")

</div>

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 / -\> returns a HTML page listing all resources  
2a. GET //(.xhtml)(/edit) -\> returns an HTML page  
containing a JS library to allow the XML data display or edition  
2b. GET //.xml(/edit) -\> returns the XML data (to edit  
or to show)

2. POST / -\> creates a new resource with the provided XML  
data (in the POST body)

3. DELETE // -\> deletes the resource

4. GET /services//? -\> 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 🙂

Antoine
