xquery via exist REST Api examples&doc.

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

xquery via exist REST Api examples&doc.

richhl
would you please give me any insight about this?

i've been encouraged by you to use REST Api over xmldb processors (see http://www.orbeon.com/ops/doc/processors-xmldb introduction note), but I have not found any example of how can one do this, I've managed to build one working example but I'm not able to get what I want (showed below return a list of collection names ang aggregate them using a container node).

    <p:processor name="oxf:xslt">
    <p:input name="data" href="#instance"/>
    <p:input name="config">
        <exist:query xmlns:exist="http://exist.sourceforge.net/NS/exist" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xsl:version="2.0">
        <exist:text>
            xquery version "1.0";
            declare namespace xmldb="http://exist-db.org/xquery/xmldb";
            let $collection-name := '/db/orbeon/neuro/<xsl:value-of select="/parametros/id_hospital"/>/'
           
 Offending line>>>   <expedientes>
                for $resource-name in xmldb:get-child-collections($collection-name)
                    return $resource-name
 Offending line>>>   </expedientes>
           
        </exist:text>
        </exist:query>
    </p:input>
    <p:output name="data" id="consulta"/>
    </p:processor>

    <!-- Ejecutar el REST submission -->
    <p:processor name="oxf:xforms-submission">
        <p:input name="submission">
            <xforms:submission xmlns:xforms="http://www.w3.org/2002/xforms"
                 method="post" action="/exist/rest/db/orbeon/neuro/"/>
        </p:input>
        <p:input name="request" href="#consulta"/>
        <p:output name="response" debug="consultaExpedientes" ref="data"/>
    </p:processor>

This example works if I drop away the offending lines..

thx a lot


--
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
Reply | Threaded
Open this post in threaded view
|

Re: xquery via exist REST Api examples&doc.

Erik Bruchez
Administrator
Richard,

The issue I think is that <exist:text> expects a query in plain text,  
that is with no nested elements. So try changing:

   <expedientes>

to:

   &lt;expedientes>

-Erik

On Nov 19, 2008, at 5:14 AM, Richard C. Hidalgo Lorite wrote:

> would you please give me any insight about this?
>
> i've been encouraged by you to use REST Api over xmldb processors  
> (see http://www.orbeon.com/ops/doc/processors-xmldb introduction  
> note), but I have not found any example of how can one do this, I've  
> managed to build one working example but I'm not able to get what I  
> want (showed below return a list of collection names ang aggregate  
> them using a container node).
>
>    <p:processor name="oxf:xslt">
>    <p:input name="data" href="#instance"/>
>    <p:input name="config">
>        <exist:query xmlns:exist="http://exist.sourceforge.net/NS/ 
> exist" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"  
> xsl:version="2.0">
>        <exist:text>
>            xquery version "1.0";
>            declare namespace xmldb="http://exist-db.org/xquery/xmldb";
>            let $collection-name := '/db/orbeon/neuro/<xsl:value-of  
> select="/parametros/id_hospital"/>/'
>
> Offending line>>>   <expedientes>
>                 for $resource-name in xmldb:get-child-
> collections($collection-name)
>                     return $resource-name
> Offending line>>>   </expedientes>
>
>        </exist:text>
>        </exist:query>
>    </p:input>
>    <p:output name="data" id="consulta"/>
>    </p:processor>
>
>    <!-- Ejecutar el REST submission -->
>    <p:processor name="oxf:xforms-submission">
>        <p:input name="submission">
>            <xforms:submission xmlns:xforms="http://www.w3.org/2002/xforms 
> "
>                 method="post" action="/exist/rest/db/orbeon/neuro/"/>
>        </p:input>
>        <p:input name="request" href="#consulta"/>
>        <p:output name="response" debug="consultaExpedientes"  
> ref="data"/>
>    </p:processor>
>
> This example works if I drop away the offending lines..
>
> thx a lot
>
> --
> 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
--
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
OW2 mailing lists service home page: http://www.ow2.org/wws
Reply | Threaded
Open this post in threaded view
|

re: Re: xquery via exist REST Api examples&doc.

richhl
In reply to this post by richhl
>So try
>changing:
>
>   <expedientes>
>
>to:
>
>   <expedientes>

oooops. I see no difference!

going to share the findings researching about this stuff.
I've used the eXist query client against the orbeon exist
servlet withi this:

let $collection-name := '/db/orbeon/neuro/demo/'
for $resource-name in
xmldb:get-child-collections($collection-name)
                order by $resource-name
                return
                <expediente numero="{$resource-name}">
{
                        for $valoracion in
xmldb:get-child-resources(fn:concat($collection-name,$resource-name
,'/escalas/barthel/'))
                        let $valoracion-actual :=
fn:doc(fn:concat($collection-name,$resource-name,'/escalas/barthel/'
,$valoracion))/cuestionario-relleno
                        return $valoracion-actual/fecha
}
                </expediente>

and it throws a correct result like this:

<expediente numero="1">
    <fecha>2008-11-13</fecha>
    <fecha>2008-10-01</fecha>
</expediente>
<expediente numero="87978">
    <fecha>2008-10-01</fecha>
    <fecha>2008-11-08</fecha>
    <fecha>2008-12-07</fecha>
    <fecha>2009-01-02</fecha>
    <fecha>2009-02-08</fecha>
    <fecha>2009-03-06</fecha>
</expediente>

using this query as text for the rest submitting, i've first
got a 2008-11-19 18:43:10,115 DEBUG XFormsServer  - XForms -
      submission - setting request body {mediatype:
"application/xml", body: "<?xml version="1.0" enco
ding="UTF-8"?><exist:query
xmlns:exist="http://exist.sourceforge.net/NS/exist"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:p="http://www.orbeon.com/oxf
/pipeline" xmlns:oxf="http://www.orbeon.com/oxf/processors"
xmlns:xdb="http://orbeon.org/oxf/xml/xmldb"
xmlns:xu="http://www.xmldb.org/xupdate"><exist:text>
            xquery version "1.0";
            declare namespace
xmldb="http://exist-db.org/xquery/xmldb";
            let $collection-name := '/db/orbeon/neuro/demo/'
            for $resource-name in
xmldb:get-child-collections($collection-name)
                order by $resource-name
                return
                <expediente numero="{$resource-name}">
{
                        for $valoracion in
xmldb:get-child-resources(fn:concat($collection-name,$resource-name
,'/escalas/barthel/'))
                        let $valoracion-actual :=
fn:doc(fn:concat($collection-name,$resource-name,'/escalas/barthel/'
,$valoracion))/cuestionario-relleno
                        return $valoracion-actual/fecha
}
                </expediente></exist:text></exist:query>"}
2008-11-19 18:43:10,155 DEBUG XQuery  -
org.exist.xquery.XPathException: err:XPST0003 in line 8,
column 17: unexpected token: null

2008-11-19 18:43:10,157 DEBUG XFormsServer  - XForms -      
submission - replacing instance with mutable instance
{instance: "default-instance"}
2008-11-19 18:43:10,167 ERROR XFormsServer  - XForms -
submission - error while reading response body
org.orbeon.oxf.common.OXFException: Stream closed





--
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
Reply | Threaded
Open this post in threaded view
|

Re: re: Re: xquery via exist REST Api examples&doc.

Erik Bruchez
Administrator
>> So try
>> changing:
>>
>>  <expedientes>
>>
>> to:
>>
>>  <expedientes>
>
> oooops. I see no difference!

Mmh, broken client, either on my side your your side (and/or broken  
Nabble?). The difference is was trying to express was that you should  
escape the opening brackets. Instead of writing a literal "<", write  
"ampersand-lt-semicolon".

-Erik

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

re: Re: re: Re: xquery via exist REST Api examples&doc.

richhl
In reply to this post by richhl
>Mmh, broken client, either on my side your your side
>(and/or broken   Nabble?). The difference is was trying to
>express was that you should   escape the opening brackets.
>Instead of writing a literal "<", write  
>"ampersand-lt-semicolon".
>
>-Erik)

I love you! it worksssssssssssssssssssssss :-)


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