Thanks Ken and James for your valuable feedback...

The issue was with transaction...so I used James' suggested technique, coz I am 
using Lib. Module not main module, so can't use ';'.
-----Original Message-----
From: [email protected] 
[mailto:[email protected]] On Behalf Of 
[email protected]
Sent: Sunday, December 06, 2009 1:30 AM
To: [email protected]
Subject: General Digest, Vol 66, Issue 10

Send General mailing list submissions to
        [email protected]

To subscribe or unsubscribe via the World Wide Web, visit
        http://xqzone.com/mailman/listinfo/general
or, via email, send a message with subject or body 'help' to
        [email protected]

You can reach the person managing the list at
        [email protected]

When replying, please edit your Subject line so it is more specific
than "Re: Contents of General digest..."


Today's Topics:

   1. RE: Not able to retrive content from uri (Michael Sokolov)
   2. Re: Not able to retrive content from  uri (G. Ken Holman)
   3. URI rewriting and original request URI (Florent Georges)
   4. RE: Not able to retrive content from  uri (James Clippinger)
   5. RE: URI rewriting and original request URI (Danny Sokolsky)


----------------------------------------------------------------------

Message: 1
Date: Sat, 5 Dec 2009 10:08:39 -0500
From: "Michael Sokolov" <[email protected]>
Subject: RE: [MarkLogic Dev General] Not able to retrive content from
        uri
To: "'General Mark Logic Developer Discussion'"
        <[email protected]>
Message-ID: <[email protected]>
Content-Type: text/plain; charset="us-ascii"

These are actually being executed as a single transaction: updates aren't
visible until *after* the transaction completes.  I think you could use ";"
instead of "," and get the result you're after
 
-Mike


  _____  

From: [email protected]
[mailto:[email protected]] On Behalf Of Chowdhury,
Soumadri
Sent: Saturday, December 05, 2009 8:19 AM
To: [email protected]
Subject: [MarkLogic Dev General] Not able to retrive content from uri



Hi,

 

I have written two consecutive FLOWR expressions like the following,

 

let $a1 := "" return (xdmp:document-insert("/demo010",<a>data</a>)),

let $a2 := "" return (fn:doc("/demo010"))

 

The problem is the 2nd line returns an empty sequence, instead of the
content of the uri "/demo010"

 

How to resolve this problem? Any idea?

 

Thanks & Regards,

Soumadri Roy

 



  _____  

Disclaimer:
-----------

"This e-mail and any files transmitted with it are for the sole use of the
intended recipient(s) and may contain confidential and privileged
information. If you are not the intended recipient, please contact the
sender by reply e-mail and destroy all copies of the original message. Any
unauthorized review, use, disclosure, dissemination, forwarding, printing or
copying of this e-mail or any action taken in reliance on this e-mail is
strictly prohibited and may be unlawful."




-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
http://xqzone.marklogic.com/pipermail/general/attachments/20091205/3fd105b4/attachment-0001.html

------------------------------

Message: 2
Date: Sat, 05 Dec 2009 10:07:48 -0500
From: "G. Ken Holman" <[email protected]>
Subject: Re: [MarkLogic Dev General] Not able to retrive content from
        uri
To: <[email protected]>
Message-ID: <[email protected]>
Content-Type: text/plain; charset="us-ascii"; format=flowed

Hi again, Soumadri!

At 2009-12-05 18:49 +0530, Chowdhury, Soumadri wrote:
>I have written two consecutive FLOWR expressions like the following,
>
>let $a1 := "" return (xdmp:document-insert("/demo010",<a>data</a>)),
>let $a2 := "" return (fn:doc("/demo010"))
>
>The problem is the 2nd line returns an empty sequence, instead of 
>the content of the uri "/demo010"
>
>How to resolve this problem? Any idea?

I learned the answer recently:  it has to do with database 
transactions.  Certain database transactions are not committed to the 
database until the query is complete.

As a test I formally declared the module to be using the Mark Logic 
version of the language:

xquery version "1.0-ml";
let $a1 := "" return (xdmp:document-insert("/demo010",<a>data</a>)),
let $a2 := "" return (fn:doc("/demo010"))

... which didn't work as yours didn't work and then changed it to:

xquery version "1.0-ml";
let $a1 := "" return (xdmp:document-insert("/demo010",<a>data</a>));
let $a2 := "" return (fn:doc("/demo010"))

... which worked fine.  Note the change of the comma to a semi-colon 
at the end of the first assignment.

This is using the Mark Logic extension to XQuery of ending a query 
with a semi-colon which allows one to put multiple queries in a 
single document.  The first query ends at the semi-colon and the 
database does its business of committing all of the changes.  The 
second query is then acting on a complete database with your more 
recent addition and finds it.

Since we are now dealing with complete queries instead of portions of 
a FLWOR expression, your test can be rewritten as follows:

xquery version "1.0-ml";
xdmp:document-insert("/demo010",<a>data</a>);
fn:doc("/demo010")

I haven't yet learned *when* queries need to be flushed/committed to 
the database, and I hope someone on the list can give general 
guidelines ... but this is how I recently resolved a related Mark 
Logic database issue.

Perhaps is there a formal request one can make in a query to commit 
any uncommitted transactions?

I hope this helps.

. . . . . . . . . . . . Ken

--
XSLT/XQuery/XPath training after http://XMLPrague.cz 2010-03-15/19
Vote for your XML training:   http://www.CraneSoftwrights.com/q/i/
Crane Softwrights Ltd.          http://www.CraneSoftwrights.com/q/
Training tools: Comprehensive interactive XSLT/XPath 1.0/2.0 video
Video lesson:    http://www.youtube.com/watch?v=PrNjJCh7Ppg&fmt=18
Video overview:  http://www.youtube.com/watch?v=VTiodiij6gE&fmt=18
G. Ken Holman                 mailto:[email protected]
Male Cancer Awareness Nov'07  http://www.CraneSoftwrights.com/q/bc
Legal business disclaimers:  http://www.CraneSoftwrights.com/legal



------------------------------

Message: 3
Date: Sat, 5 Dec 2009 16:10:39 +0000 (GMT)
From: Florent Georges <[email protected]>
Subject: [MarkLogic Dev General] URI rewriting and original request
        URI
To: MarkLogic General ML <[email protected]>
Message-ID: <[email protected]>
Content-Type: text/plain; charset=utf-8

  Hi,

  I am using the URI rewriting facility of the HTTP app server.
It seems the module set as the URI rewriter sees the original URI
while the resolved module (the module that is actually evaluated
after the URI rewriting) sees the rewrited URI:

    (: uri-rewriter.xqy :)
    replace(xdmp:get-request-url(), '^/a.xqy$', '/b.xqy')

    (: b.xqy :)
    xdmp:get-request-url()

  The result is the text '/b.xqy'.

  Is there any way to access the original URI in the resolved
module?

  Regards,

-- 
Florent Georges
http://www.fgeorges.org/




















      



------------------------------

Message: 4
Date: Sat, 5 Dec 2009 10:07:02 -0800
From: James Clippinger <[email protected]>
Subject: RE: [MarkLogic Dev General] Not able to retrive content from
        uri
To: General Mark Logic Developer Discussion
        <[email protected]>
Message-ID:
        <[email protected]>
Content-Type: text/plain; charset="us-ascii"

A database transaction in MarkLogic Server is only committed when the query 
execution is complete.  Phrased another way, an update transaction will see a 
view of the database that does not reflect any updates made by that transaction.

By using a semicolon, you're putting multiple transactions in a single module 
file.  This is a very handy feature, but, due to the overhead involved in 
opening multiple transactions and complexities of managing side effects, it's 
generally best to avoid using semicolons unless necessary.  In this example, 
using a semicolon would provide a window for the document to change from the 
update value.  If another query was executed at the same time updating /demo010 
to <b>data2</b>, the value returned by the semicolon form would be determined 
by whichever query won the race.

I'd suggest doing something like:

let $new := <a>data</a>
return (xdmp:document-insert("/demo010", $new), $new)

This approach works because $new will only actually be returned if the insert 
is successful; otherwise, the query will return an error.

James

-----Original Message-----
From: [email protected] 
[mailto:[email protected]] On Behalf Of G. Ken Holman
Sent: Saturday, December 05, 2009 10:08 AM
To: [email protected]
Subject: Re: [MarkLogic Dev General] Not able to retrive content from uri

Hi again, Soumadri!

At 2009-12-05 18:49 +0530, Chowdhury, Soumadri wrote:
>I have written two consecutive FLOWR expressions like the following,
>
>let $a1 := "" return (xdmp:document-insert("/demo010",<a>data</a>)),
>let $a2 := "" return (fn:doc("/demo010"))
>
>The problem is the 2nd line returns an empty sequence, instead of 
>the content of the uri "/demo010"
>
>How to resolve this problem? Any idea?

I learned the answer recently:  it has to do with database 
transactions.  Certain database transactions are not committed to the 
database until the query is complete.

As a test I formally declared the module to be using the Mark Logic 
version of the language:

xquery version "1.0-ml";
let $a1 := "" return (xdmp:document-insert("/demo010",<a>data</a>)),
let $a2 := "" return (fn:doc("/demo010"))

... which didn't work as yours didn't work and then changed it to:

xquery version "1.0-ml";
let $a1 := "" return (xdmp:document-insert("/demo010",<a>data</a>));
let $a2 := "" return (fn:doc("/demo010"))

... which worked fine.  Note the change of the comma to a semi-colon 
at the end of the first assignment.

This is using the Mark Logic extension to XQuery of ending a query 
with a semi-colon which allows one to put multiple queries in a 
single document.  The first query ends at the semi-colon and the 
database does its business of committing all of the changes.  The 
second query is then acting on a complete database with your more 
recent addition and finds it.

Since we are now dealing with complete queries instead of portions of 
a FLWOR expression, your test can be rewritten as follows:

xquery version "1.0-ml";
xdmp:document-insert("/demo010",<a>data</a>);
fn:doc("/demo010")

I haven't yet learned *when* queries need to be flushed/committed to 
the database, and I hope someone on the list can give general 
guidelines ... but this is how I recently resolved a related Mark 
Logic database issue.

Perhaps is there a formal request one can make in a query to commit 
any uncommitted transactions?

I hope this helps.

. . . . . . . . . . . . Ken

--
XSLT/XQuery/XPath training after http://XMLPrague.cz 2010-03-15/19
Vote for your XML training:   http://www.CraneSoftwrights.com/q/i/
Crane Softwrights Ltd.          http://www.CraneSoftwrights.com/q/
Training tools: Comprehensive interactive XSLT/XPath 1.0/2.0 video
Video lesson:    http://www.youtube.com/watch?v=PrNjJCh7Ppg&fmt=18
Video overview:  http://www.youtube.com/watch?v=VTiodiij6gE&fmt=18
G. Ken Holman                 mailto:[email protected]
Male Cancer Awareness Nov'07  http://www.CraneSoftwrights.com/q/bc
Legal business disclaimers:  http://www.CraneSoftwrights.com/legal

_______________________________________________
General mailing list
[email protected]
http://xqzone.com/mailman/listinfo/general


------------------------------

Message: 5
Date: Sat, 5 Dec 2009 11:34:03 -0800
From: Danny Sokolsky <[email protected]>
Subject: RE: [MarkLogic Dev General] URI rewriting and original
        request URI
To: "[email protected]" <[email protected]>,  General Mark Logic
        Developer Discussion <[email protected]>
Message-ID:
        <[email protected]>
Content-Type: text/plain; charset="us-ascii"

Hi Florent,

You can have your URL rewriter pass the value of xdmp:get-request-url as a 
parameter to your module, then you can use that in your module.

-Danny

________________________________________
From: [email protected] 
[[email protected]] On Behalf Of Florent Georges 
[[email protected]]
Sent: Saturday, December 05, 2009 8:10 AM
To: MarkLogic General ML
Subject: [MarkLogic Dev General] URI rewriting and original request URI

  Hi,

  I am using the URI rewriting facility of the HTTP app server.
It seems the module set as the URI rewriter sees the original URI
while the resolved module (the module that is actually evaluated
after the URI rewriting) sees the rewrited URI:

    (: uri-rewriter.xqy :)
    replace(xdmp:get-request-url(), '^/a.xqy$', '/b.xqy')

    (: b.xqy :)
    xdmp:get-request-url()

  The result is the text '/b.xqy'.

  Is there any way to access the original URI in the resolved
module?

  Regards,

--
Florent Georges
http://www.fgeorges.org/






















_______________________________________________
General mailing list
[email protected]
http://xqzone.com/mailman/listinfo/general


------------------------------

_______________________________________________
General mailing list
[email protected]
http://xqzone.com/mailman/listinfo/general


End of General Digest, Vol 66, Issue 10
***************************************
_______________________________________________
General mailing list
[email protected]
http://xqzone.com/mailman/listinfo/general

Reply via email to