Using the REST processors from XForms

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Using the REST processors from XForms

Paul Saxelby
Hi all.

Many thanks for the help to date.

The previous problem that I was having with the form data not getting
to the exist database has been solved for the meantime by running the
server on an XP machine instead of a Vista one.
The form now works exactly as I posted it...

My one remaining problem is (I think) just one of using the correct
processor from within XForms.

At the moment the submission is done using:

<xforms:submission id="save-submission"
ref="instance('questionnaires-instance')"
action="/exist/rest/db/orbeon/my-bookcast/books.xml" method="put"
replace="none" >
    <xforms:message ev:event="xforms-submit-error" level="modal">
        An error occurred while saving!
    </xforms:message>
</xforms:submission>


This replaces the entry in the database using REST (I think).
The equivalent calling the XForms submission processor is (I think):

<p:config>
    <p:processor name="oxf:xforms-submission">
        <p:input name="submission">
            <xforms:submission method="put"
action="/exist/rest/db/orbeon/my-bookcast/books.xml"/>
        </p:input>
        <p:input name="request">
            <gaga/>
        </p:input>
        <p:output name="response" id="dummy"/>
    </p:processor>
    <p:processor name="oxf:null-serializer">
        <p:input name="data" href="#dummy"/>
    </p:processor>
</p:config>

(what is the <gaga/> bit?).


Replacing the data is not what I need to do though, I need to add nodes
I have looked through the documentation that I can find on how to do
this, and there's an example in the second style.
The documentation seems to say that each of the examples given can be
done either directly from the XForms, or by calling the XForms
submission processor.


The one I think I need to use is:

<p:processor name="oxf:xmldb-insert">
    <p:input name="datasource" href="datasource.xml"/>
    <p:input name="query">
        <xdb:insert collection="/db/ops/dmv-example"/>
    </p:input>
    <p:input name="data" href="#document-info"/>
</p:processor>

The documentation seems to say that I will also need to set up the datasource:

<!-- For instance, to connect to an embedded eXist, use: -->
<datasource>
    <driver-class-name>org.exist.xmldb.DatabaseImpl</driver-class-name>
    <uri>xmldb:exist:///</uri>
    <username>admin</username>
    <password>admin</password>
</datasource>

I've tried to find some documentation that explains how & where in the
structure of the XForms document to do the above two things, but I
can't find it anywhere.

Does anyone know how to do this please?


Best regards,
Paul



--
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
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: Using the REST processors from XForms

Erik Bruchez
Administrator
Paul,

Using the XML:DB processors will allow you to insert documents into
eXist with eXist automatically creating names for the files, but I don't
think it's reasonable at this point to change your application to use
those processors.

Instead, I think the approach you have been looking at, which consists
in dynamically generating the file name in XForms, is simpler and I just
recommend you keep trying in that direction.

-Erik

Paul Saxelby wrote:

> Hi all.
>
> Many thanks for the help to date.
>
> The previous problem that I was having with the form data not getting
> to the exist database has been solved for the meantime by running the
> server on an XP machine instead of a Vista one.
> The form now works exactly as I posted it...
>
> My one remaining problem is (I think) just one of using the correct
> processor from within XForms.
>
> At the moment the submission is done using:
>
> <xforms:submission id="save-submission"
> ref="instance('questionnaires-instance')"
> action="/exist/rest/db/orbeon/my-bookcast/books.xml" method="put"
> replace="none" >
>    <xforms:message ev:event="xforms-submit-error" level="modal">
>        An error occurred while saving!
>    </xforms:message>
> </xforms:submission>
>
>
> This replaces the entry in the database using REST (I think).
> The equivalent calling the XForms submission processor is (I think):
>
> <p:config>
>    <p:processor name="oxf:xforms-submission">
>        <p:input name="submission">
>            <xforms:submission method="put"
> action="/exist/rest/db/orbeon/my-bookcast/books.xml"/>
>        </p:input>
>        <p:input name="request">
>            <gaga/>
>        </p:input>
>        <p:output name="response" id="dummy"/>
>    </p:processor>
>    <p:processor name="oxf:null-serializer">
>        <p:input name="data" href="#dummy"/>
>    </p:processor>
> </p:config>
>
> (what is the <gaga/> bit?).
>
>
> Replacing the data is not what I need to do though, I need to add nodes
> I have looked through the documentation that I can find on how to do
> this, and there's an example in the second style.
> The documentation seems to say that each of the examples given can be
> done either directly from the XForms, or by calling the XForms
> submission processor.
>
>
> The one I think I need to use is:
>
> <p:processor name="oxf:xmldb-insert">
>    <p:input name="datasource" href="datasource.xml"/>
>    <p:input name="query">
>        <xdb:insert collection="/db/ops/dmv-example"/>
>    </p:input>
>    <p:input name="data" href="#document-info"/>
> </p:processor>
>
> The documentation seems to say that I will also need to set up the
> datasource:
>
> <!-- For instance, to connect to an embedded eXist, use: -->
> <datasource>
>    <driver-class-name>org.exist.xmldb.DatabaseImpl</driver-class-name>
>    <uri>xmldb:exist:///</uri>
>    <username>admin</username>
>    <password>admin</password>
> </datasource>
>
> I've tried to find some documentation that explains how & where in the
> structure of the XForms document to do the above two things, but I
> can't find it anywhere.
>
> Does anyone know how to do this please?
>
>
> Best regards,
> Paul
>

--
Orbeon Forms - Web Forms for the Enterprise Done the Right Way
http://www.orbeon.com/



--
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
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: Using the REST processors from XForms

bicyclesforeveryone
I have this same question but I don't understand the previous response...

I have an xform that I would like to use to add nodes (an organization) to an existing document (of organizations). The user would typically not need to deal with other organizations, only their own.

From what I understand, I cannot use the REST API, because that replaces the entire document whereas I only want to add an <organization />. I should use the XML:DB API? Are there better examples than the XML:DB API section of the documentation?

Reply | Threaded
Open this post in threaded view
|

Re: Re: Using the REST processors from XForms

Alessandro Vernet
Administrator
On Wed, Jun 11, 2008 at 1:29 PM, bicyclesforeveryone
<[hidden email]> wrote:
> From what I understand, I cannot use the REST API, because that replaces the
> entire document whereas I only want to add an <organization />. I should use
> the XML:DB API? Are there better examples than the XML:DB API section of the
> documentation?

You can do this in XQuery with the XQuery Update Extensions. You can
find more about those on the page linked below. You can then send you
XQuery to the eXist REST API either with a POST or a GET.

http://exist.sourceforge.net/update_ext.html

Alex
--
Orbeon Forms - Web 2.0 Forms, open-source, for the Enterprise
Orbeon's Blog: http://www.orbeon.com/blog/
Personal Blog: http://avernet.blogspot.com/
Twitter - http://twitter.com/avernet


--
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