You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by "Rui Alberto L. Gonçalves" <ru...@ptinovacao.pt> on 2004/07/13 21:46:07 UTC

updating documents problems - eXist and cocoon

Hi all,

I've passed two days trying to figure out a solution to my
problem..so, I'm posting this message in the hope that someone
here could come up with an idea...

I'm using cocoon+eXist and using XQueryGenerator to perform
all the required operations in the database.

The problem is:
I need perform an XUpdate in a document in the database, but 
the new data to be inserted in the document is returned by a 
cocoon pipeline. 

The XQuery script to XQueryGenerator that I would like to have:
------------------
xquery version "1.0";

...
declare variable $xupdate {
<xu:modifications version="1.0" xmlns:xu="http://www.xmldb.org/xupdate">
      <xu:append select="/root-censorship" >
        <censorship datasource="{$star}">
           <xinclude:include  href="cocoon:/NEW_DATA_TO_BE_INSERTED"/>
        </censorship>
      </xu:append>
    </xu:modifications>
};

let $dburi := concat("xmldb:exist:///db/users/", $login,"/datasources"),
    $root := xmldb:collection($dburi, "admin", "")
return
   <result>{xmldb:update($root, $xupdate)} modifications </result>


1) XQueryGenerator doesn't resolve xinclude before execute, so this 
approach doesn't work.

2) I can't produce  the script XQuery dynamically in a cocoon 
pipeline, because XQuery script is not XML. Otherwise I could do
something like:
...
<map:generate type="xquery" src="cocoon:/generate_xquery_script"/>
...

3) Cocoon XMLDBTransformer doesn't work with exist. The XMLDBTransformer
that is shipped with exist only allows to perform select type
 operations!

Any idea? Thanks to all.

Rui



-- 
Rui Alberto L. Gonçalves <ru...@ptinovacao.pt>
PT Inovação


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: updating documents problems - eXist and cocoon

Posted by Bruce Robertson <br...@mta.ca>.
Quoting "Rui Alberto L. Gonçalves" <ru...@ptinovacao.pt>:

> Hi all,
> 
> I've passed two days trying to figure out a solution to my
> problem..so, I'm posting this message in the hope that someone
> here could come up with an idea...
> 
> I'm using cocoon+eXist and using XQueryGenerator to perform
> all the required operations in the database.
> 
> The problem is:
> I need perform an XUpdate in a document in the database, but 
> the new data to be inserted in the document is returned by a 
> cocoon pipeline. 
> 
> The XQuery script to XQueryGenerator that I would like to have:
> ------------------
> xquery version "1.0";
> 
> ...
> declare variable $xupdate {
> <xu:modifications version="1.0"
> xmlns:xu="http://www.xmldb.org/xupdate">
>       <xu:append select="/root-censorship" >
>         <censorship datasource="{$star}">
>            <xinclude:include  href="cocoon:/NEW_DATA_TO_BE_INSERTED"/>
>         </censorship>
>       </xu:append>
>     </xu:modifications>
> };
> 
> let $dburi := concat("xmldb:exist:///db/users/",
> $login,"/datasources"),
>     $root := xmldb:collection($dburi, "admin", "")
> return
>    <result>{xmldb:update($root, $xupdate)} modifications </result>
> 
> 
> 1) XQueryGenerator doesn't resolve xinclude before execute, so this 
> approach doesn't work.
> 
> 2) I can't produce  the script XQuery dynamically in a cocoon 
> pipeline, because XQuery script is not XML. Otherwise I could do
> something like:
> ...
> <map:generate type="xquery" src="cocoon:/generate_xquery_script"/>
> ...
> 
> 3) Cocoon XMLDBTransformer doesn't work with exist. The
> XMLDBTransformer
> that is shipped with exist only allows to perform select type
>  operations!
> 
> Any idea? Thanks to all.
> 
> Rui
>

[I've cross-posted this to the eXist-open list, where I believe further
responses should be posted.]

I ran into this brick wall, too, when trying to somehow add a document to
the database from a cocoon pipeline. My first attempt involved generating
xquery statements that would do so and calling these dynamically into a
XQueryGenerator. The problem I found was that xq statements are not xml but
have xml in them. You can't use the text serializer for the generated
xquery statements (or you'll loose your xml), and you can't call it xml or
the serializer will fail. 

Perhaps you could generate the xquery wrapped in some root element, then
within XQueryGenerator perform a xsl to strip the root element and the call
a execute on what results. 

Since I didn't need xupdate (just document loading), I instead modified the
xadmin code to work with cocoon:/ URIs as described in:
http://wiki.exist-db.org/space/HowTos/Load+Document+Within+Cocoon
and mentioned in a posting on exist-open-l earlier today.

Thinking out loud, I wonder if what we need is an XQueryTransformer, which
takes an xml document comprising a root element containing an xquery
statement and executes it. Or is xquery so different that it can't be
expressed as an xml document fragment?

Yrs,
-- 
Bruce Robertson, 
Dept. of Classics, Mount Allison University
http://heml.mta.ca

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org