Querying an XML database (eXist-db)

Posted by Markku Laine on
URL: https://discuss.orbeon.com/Querying-an-XML-database-eXist-db-tp1459077.html

Hi,


I would like to execute an XQuery expression against data stored in
eXist-db. I know that there are a couple of different approaches for doing
that so I thought, hey, let's try them all in order to compare the
different approaches.

First, I decided to try out eXist-db's REST API. The following code on my
XHTML+XForms Web page worked fine (eXist-db is running as a separate Web
application):
------------- 8< -------------
...
<xforms:model>
   <xforms:instance id="courses-instance">
     <dummy xmlns="" />
   </xforms:instance>
   <xforms:submission id="select-courses-submission"
serialization="none" method="get"
resource="http://localhost:8080/exist/rest/db/courses/courses.xml?_query=//courses&amp;_wrap=no"
replace="instance" instance="courses-instance" />
   <xforms:send submission="select-courses-submission"
ev:event="xforms-ready" />
</xforms:model>
...
--------------- 8< -------------


Next, I wanted to try out Orbeon Forms' XForms Submission Processor. I
modified my page-flow.xml a bit, which looked like this after the
modifications:
<?xml version="1.0" encoding="UTF-8"?>
<config xmlns="http://www.orbeon.com/oxf/controller">
   <page path-info="/my-app/" view="view2.xhtml"/>
   <page path-info="/my-app/selectcourses"
model="select_courses.xpl" />
   <epilogue url="oxf:/config/epilogue.xpl"/>
</config>

And added the select_courses.xpl file:
<?xml version="1.0" encoding="utf-8"?>
<p:config xmlns:p="http://www.orbeon.com/oxf/pipeline"
     xmlns:oxf="http://www.orbeon.com/oxf/processors"
     xmlns:xforms="http://www.w3.org/2002/xforms"
     xmlns:xxforms="http://orbeon.org/oxf/xml/xforms">
   <p:param name="data" type="output" />
   <p:processor name="oxf:xforms-submission">
     <p:input name="submission">
       <xforms:submission method="get"
action="http://localhost:8080/exist/rest/db/courses/courses.xml?_query=//courses&amp;_wrap=no"
xxforms:username="guest" xxforms:password="guest" />
     </p:input>
     <p:input name="request">
       <parameters/>
     </p:input>
     <p:output name="response" ref="data" />
   </p:processor>

</p:config>

Here is a code snippet from view2.xhtml:
------- 8< ------------
...
<xforms:model>
   <xforms:instance id="courses-instance">
     <dummy xmlns="" />
   </xforms:instance>
   <xforms:insert nodeset="instance( 'courses-instance' )"
origin="xxforms:call-xpl(
'oxf:/apps/my-app/select_courses.xpl', 'data', instance(
'courses-instance' ), 'data' )" ev:event="xforms-ready" />
</xforms:model>
...
------------- 8< -------------

The aforementioned example works fine and I am able to retrieve the data
from the database.


Then, I tried to do the same but without using the call-xpl() solution. I
never managed to make it work :( Could somebody help me out with this one,
and provide me a working solution (XHTML+XForms code + XPL code) with
explanations?!?

I would also like to know what changes I need to make in order to use the
approach described here:
http://www.orbeon.com/orbeon/doc/processors-xmldb#xmldb

Kind regards


-Markku


--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws