Hi Helen,

It is a subtle typo. It sometimes helps to take the query from inside the eval, 
and test it all by itself in CQ. If you do so, you see the same 'unexpected 
token' message as you would get when it is inside the eval, but you get a 
better focus on which line it concerns. In this case it concerns your external 
variable declarations. There should be no 'as' before the external keyword..

Kind regards,
Geert

>


drs. G.P.H. (Geert) Josten
Consultant

Daidalos BV
Hoekeindsehof 1-4
2665 JZ Bleiswijk

T +31 (0)10 850 1200
F +31 (0)10 850 1199

mailto:[email protected]
http://www.daidalos.nl/

KvK 27164984


De informatie - verzonden in of met dit e-mailbericht - is afkomstig van 
Daidalos BV en is uitsluitend bestemd voor de geadresseerde. Indien u dit 
bericht onbedoeld hebt ontvangen, verzoeken wij u het te verwijderen. Aan dit 
bericht kunnen geen rechten worden ontleend.

> From: [email protected]
> [mailto:[email protected]] On Behalf Of
> Helen Chen
> Sent: woensdag 7 juli 2010 4:03
> To: General Mark Logic Developer Discussion
> Subject: Re: [MarkLogic Dev General] how to do
> multi-transaction in a function
>
> Hi Danny,
>
> it works with plain query. usually in my function I have some
> variables and I need to use these variables for eval. I tried
> the following and I couldn't make it work. Can you help me?
>
> xquery version "1.0-ml";
>
> declare function local:mytest()
> {
> let $c1 := "http://py";
> let $c2 := "http://mytest";
> return
> (
> xdmp:eval('xdmp:document-insert("/aa.xml", <foo/>)') ,
> xdmp:eval('xquery version "1.0-ml";
>            declare variable $e1 as external;
>            declare variable $e2 as external;
>            xdmp:document-set-collections( "/aa.xml", ($e1))
>            ,
>            xdmp:document-get-collections("/aa.xml")
>            ,
>            xdmp:document-add-collections( "/aa.xml", ($e2))'
>           ,
>           (xs:QName("e1"), $c1, xs:QName("e2"), $c2)
>
>          )
> ,
> xdmp:eval('xdmp:document-get-collections("/aa.xml")')
> )
> };
>
> local:mytest()
>
>
>
>
>
> On Jul 6, 2010, at 5:18 PM, Danny Sokolsky wrote:
>
>
>       You need to make the updates happen in a separate
> transaction and then make the get-collections happen in a
> separate transaction that has a timestamp later than the
> update.  One way to do that is by making them each do evals.
> SOmething like:
>
>       xquery version "1.0-ml";
>       declare function local:mytest()
>       {
>       (
>       xdmp:eval('xdmp:document-insert("/aa.xml", <foo/>)'),
>       xdmp:eval('xdmp:document-set-collections( "/aa.xml",
> ("http://py";))
>       ,
>       xdmp:document-get-collections("/aa.xml")
>       ,
>       xdmp:document-add-collections( "/aa.xml", ("http://mytest";))')
>       ,
>       xdmp:eval('xdmp:document-get-collections("/aa.xml")')
>       )
>       };
>
>       local:mytest()
>
>       -Danny
>
>       From: [email protected]
> [mailto:[email protected]] On Behalf Of
> helen chen
>       Sent: Tuesday, July 06, 2010 2:03 PM
>       To: General Mark Logic Developer Discussion
>       Subject: [MarkLogic Dev General] how to do
> multi-transaction in a function
>
>       I want to do an update to a document and then see the
> update immediately. I did a test like the following:
>       I add a collection to a document, then try to get it,
> within the same transaction I cannot see the new collection.
> That means I have to be in the seperate transaction.
>
>       declare function local:mytest()
>       {
>       (
>       xdmp:document-set-collections( "/aa.xml", ("http://py";))
>       ,
>       xdmp:document-get-collections("/aa.xml")
>       ,
>       xdmp:document-add-collections( "/aa.xml", ("http://mytest";))
>       ,
>       xdmp:document-get-collections("/aa.xml")
>       )
>       };
>
>       local:mytest()
>
>
>       How can I make the last line
> xdmp:document-get-collections("/aa.xml") as seperate
> transaction so I can see the change?
>
>       Thanks, Helen
>       _______________________________________________
>       General mailing list
>       [email protected]
>       http://developer.marklogic.com/mailman/listinfo/general
>
>
>
>
_______________________________________________
General mailing list
[email protected]
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to