interpolating into xquery?

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

interpolating into xquery?

Mike Leary
I want to parameterize an xquery I've borrowed from the
summary-query.xml in the gov't forms app.  The following doesn't work;
how can I get the desired result?


in the model of the xhtml view there is:

<xforms:action ev:event="xforms-ready">

    <xforms:insert nodeset="xxforms:instance('list-documents-query')"
        origin="doc('oxf:/apps/nexus/secure/summary-query.xml')"/>

    <xforms:send submission="list-documents-submission"/>

</xforms:action>


in summary-query is:

<exist:query xmlns:exist="http://exist.sourceforge.net/NS/exist">
    <exist:text>
        xquery version "1.0";
        declare namespace xmldb="http://exist-db.org/xquery/xmldb";
        &lt;documents>
            &lt;headers>
                &lt;header>Album&lt;/header>
                &lt;header>Artist&lt;/header>
            &lt;/headers>
            {
<!-- ** HERE ** -->
                let $collection-name :=
      '/db/collection/{xxforms:instance('some-instance')/username}/'

<SNIP!>
--



--
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: interpolating into xquery?

Alessandro Vernet
Administrator
Mike,

One way is to have an instance that you use to hold the query you send
to eXist. This is the instance posted to eXist:

<xforms:instance id="query">
    <exist:query>
        <exist:text/>
    </exist:query>
</xforms:instance>

Then you have an instance which contains the "template" of your query.
Note the <username/> which will then be replaced:

<xforms:instance id="get-albums">
    <query>
        your xquery...
        <username/>
        ...xquery continues
    </query>
</xforms:instance>

Before running the submission to eXist you do:

<xforms:setvalue ref="instance('get-albums')/username" value="..."/>
<xforms:setvalue ref="instance('query')/exist:text"
        value="instance('get-albums')"/>

Because value="instance('get-albums')" takes the string value of the
get-album instance, the <username> tags go away and you are just left
with its content of that element.

Alex

On 2/5/07, Mike Leary <[hidden email]> wrote:

> I want to parameterize an xquery I've borrowed from the
> summary-query.xml in the gov't forms app.  The following doesn't work;
> how can I get the desired result?
>
>
> in the model of the xhtml view there is:
>
> <xforms:action ev:event="xforms-ready">
>
>     <xforms:insert nodeset="xxforms:instance('list-documents-query')"
>         origin="doc('oxf:/apps/nexus/secure/summary-query.xml')"/>
>
>     <xforms:send submission="list-documents-submission"/>
>
> </xforms:action>
>
>
> in summary-query is:
>
> <exist:query xmlns:exist="http://exist.sourceforge.net/NS/exist">
>     <exist:text>
>         xquery version "1.0";
>         declare namespace xmldb="http://exist-db.org/xquery/xmldb";
>         &lt;documents>
>             &lt;headers>
>                 &lt;header>Album&lt;/header>
>                 &lt;header>Artist&lt;/header>
>             &lt;/headers>
>             {
> <!-- ** HERE ** -->
>                 let $collection-name :=
>       '/db/collection/{xxforms:instance('some-instance')/username}/'
>
> <SNIP!>
> --
>
>
>
> --
> 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
>
>

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