Re: [MarkLogic Dev General] Strange issue with xdmp:node-delete

2018-02-01 Thread Geert Josten
I concur that the fact ML seems to stop responding does sound like a deadlock. 
Looking at cluster status, and inspecting the execution queues might reveal a 
request that doesn’t seem to return.

Your code is not using eval or invoke, though, so i don’t think you can create 
a deadlock with just that code. Could it be though that you are invoking below 
code from elsewhere where you might be reading or updating same kind of content?

Cheers,
Geert

From: 
mailto:general-boun...@developer.marklogic.com>>
 on behalf of David Ennis 
mailto:david.en...@marklogic.com>>
Reply-To: MarkLogic Developer Discussion 
mailto:general@developer.marklogic.com>>
Date: Thursday, February 1, 2018 at 7:30 AM
To: MarkLogic Developer Discussion 
mailto:general@developer.marklogic.com>>
Subject: Re: [MarkLogic Dev General] Strange issue with xdmp:node-delete

I think that you are getting a deadlock by referencing the element via the red 
and subsequent xpath into the document while in the same transaction trying to 
update the document.

Isolating the read of the document should work. Likewise, you can isolate the 
node-delete as well, but that could have an impact on the way you are expecting 
your transactions to work.


Please try to isolate this line into a separate transaction using 
xdmp:invoke-function()
‘let $doc := fn:doc(db:get-uri-by-rid($rid))/l:expression’
- isolation: different transaction
- update-auto-commit

You may also want to use the ‘prevent-deadlocks’ option to throw an error if 
your code has, in fact, created a deadlock situation.


My theory can be tested by removing the following lines:
let $doc := fn:doc(db:get-uri-by-rid($rid))/l:expression
$doc/l:exportChannels/l:exportChannel[@href = 
$exportlib:channel-rid-i2])/l:precomputedValues

-David


--


From: 
mailto:general-boun...@developer.marklogic.com>>
 on behalf of Lanz 
mailto:lancelot.meuril...@gmail.com>>
Reply-To: MarkLogic Developer Discussion 
mailto:general@developer.marklogic.com>>
Date: Wednesday, January 31, 2018 at 7:08 PM
To: MarkLogic Developer Discussion 
mailto:general@developer.marklogic.com>>
Subject: Re: [MarkLogic Dev General] Strange issue with xdmp:node-delete

yes Florent, it returns the doc uri

On Wed, Jan 31, 2018 at 6:53 PM, Florent Georges 
mailto:li...@fgeorges.org>> wrote:
Just in case, you can confirm that the node you are about to delete is indeed 
from a stored document with something like the following :

xdmp:log(fn:document-uri(fn:root($node)))
--
Florent Georges
H2O Consulting
http://h2o.consulting/

On 31 Jan 2018 18:47, "Lanz" 
mailto:lancelot.meuril...@gmail.com>> wrote:
Hi Mister Florent,

Thks for your answer.
There is no symptom at all: no exception, no specific log, no deletion. When I 
run the 'real' script on QConsole (or Oxygen connected through xdbc to ML), it 
returns the focus after a while (whitout SVC-EXTIME) without any deletion.
I'm trying with a colleague to simplify the script and recreate a readable case 
for everyone.
For now it seems that the sem:sparql combined with sem:store has some 
influences on this behavior

So I will come back soon with a simplified script.
Lanz


On Wed, Jan 31, 2018 at 6:26 PM, Florent Georges 
mailto:li...@fgeorges.org>> wrote:
>
> Salut Lancelot,
>
> I might have missed it, but what is the exact symptom? Any error message? 
> Have you tried the "real" script through QConsole? Any chance you simplify it 
> and post it here? More pairs of eyes might catch something you missed...
>
> Regards,
>
> --
> Florent Georges
> H2O Consulting
> http://h2o.consulting/
>
> On 30 Jan 2018 22:29, "Lanz" 
> mailto:lancelot.meuril...@gmail.com>> wrote:
>>
>> Hi all,
>>
>> I've got this strange issue with xdmp:node-delete with a node in the 
>> database with Marklogic 8.0-6.3.
>> First when I use xdmp:node-delete on the target node with the above basic 
>> script, it works:
>> 
>> xquery version "1.0-ml";
>> declare namespace html = "http://www.w3.org/1999/xhtml";;
>> declare namespace l="http://www.oecd.org/ns/lambda/schema/";;
>> import module namespace db = "http://www.oecd.org/ns/lambda/app/lib/db"; at 
>> "/app/lib/db/db.xqm";
>> import module namespace exportlib = 
>> "http://www.oecd.org/ns/lambda/app/lib/export"; at 
>> "/app/lib/export/export.xqm";
>> declare variable $keyName-parent-toc-info as xs:string := 'parent-toc-info';
>> let $rid := 'urn:oecd.org:publications:id:expression:g2g12781'
>> let $doc := fn:doc(db:get-uri-by-rid($rid))/l:expression
>> return
>> (
>> (: display parent node before

Re: [MarkLogic Dev General] Strange issue with xdmp:node-delete

2018-01-31 Thread David Ennis
I think that you are getting a deadlock by referencing the element via the red 
and subsequent xpath into the document while in the same transaction trying to 
update the document.

Isolating the read of the document should work. Likewise, you can isolate the 
node-delete as well, but that could have an impact on the way you are expecting 
your transactions to work.


Please try to isolate this line into a separate transaction using 
xdmp:invoke-function()
‘let $doc := fn:doc(db:get-uri-by-rid($rid))/l:expression’
- isolation: different transaction
- update-auto-commit

You may also want to use the ‘prevent-deadlocks’ option to throw an error if 
your code has, in fact, created a deadlock situation.


My theory can be tested by removing the following lines:
let $doc := fn:doc(db:get-uri-by-rid($rid))/l:expression
$doc/l:exportChannels/l:exportChannel[@href = 
$exportlib:channel-rid-i2])/l:precomputedValues

-David


--


From:  on behalf of Lanz 

Reply-To: MarkLogic Developer Discussion 
Date: Wednesday, January 31, 2018 at 7:08 PM
To: MarkLogic Developer Discussion 
Subject: Re: [MarkLogic Dev General] Strange issue with xdmp:node-delete

yes Florent, it returns the doc uri

On Wed, Jan 31, 2018 at 6:53 PM, Florent Georges 
mailto:li...@fgeorges.org>> wrote:
Just in case, you can confirm that the node you are about to delete is indeed 
from a stored document with something like the following :

xdmp:log(fn:document-uri(fn:root($node)))
--
Florent Georges
H2O Consulting
http://h2o.consulting/

On 31 Jan 2018 18:47, "Lanz" 
mailto:lancelot.meuril...@gmail.com>> wrote:
Hi Mister Florent,

Thks for your answer.
There is no symptom at all: no exception, no specific log, no deletion. When I 
run the 'real' script on QConsole (or Oxygen connected through xdbc to ML), it 
returns the focus after a while (whitout SVC-EXTIME) without any deletion.
I'm trying with a colleague to simplify the script and recreate a readable case 
for everyone.
For now it seems that the sem:sparql combined with sem:store has some 
influences on this behavior

So I will come back soon with a simplified script.
Lanz


On Wed, Jan 31, 2018 at 6:26 PM, Florent Georges 
mailto:li...@fgeorges.org>> wrote:
>
> Salut Lancelot,
>
> I might have missed it, but what is the exact symptom? Any error message? 
> Have you tried the "real" script through QConsole? Any chance you simplify it 
> and post it here? More pairs of eyes might catch something you missed...
>
> Regards,
>
> --
> Florent Georges
> H2O Consulting
> http://h2o.consulting/
>
> On 30 Jan 2018 22:29, "Lanz" 
> mailto:lancelot.meuril...@gmail.com>> wrote:
>>
>> Hi all,
>>
>> I've got this strange issue with xdmp:node-delete with a node in the 
>> database with Marklogic 8.0-6.3.
>> First when I use xdmp:node-delete on the target node with the above basic 
>> script, it works:
>> 
>> xquery version "1.0-ml";
>> declare namespace html = "http://www.w3.org/1999/xhtml";;
>> declare namespace l="http://www.oecd.org/ns/lambda/schema/";;
>> import module namespace db = "http://www.oecd.org/ns/lambda/app/lib/db"; at 
>> "/app/lib/db/db.xqm";
>> import module namespace exportlib = 
>> "http://www.oecd.org/ns/lambda/app/lib/export"; at 
>> "/app/lib/export/export.xqm";
>> declare variable $keyName-parent-toc-info as xs:string := 'parent-toc-info';
>> let $rid := 'urn:oecd.org:publications:id:expression:g2g12781'
>> let $doc := fn:doc(db:get-uri-by-rid($rid))/l:expression
>> return
>> (
>> (: display parent node before child node deletion :)
>> $doc/l:exportChannels/l:exportChannel[@href = 
>> $exportlib:channel-rid-i2])/l:precomputedValues
>> ,xdmp:node-delete($doc/l:exportChannels/l:exportChannel[@href = 
>> $exportlib:channel-rid-i2])/l:precomputedValues/l:precomputedValue[@key = 
>> $keyName-parent-toc-info]
>> )
>> 
>> The node 'l:precomputedValues[l:precomputedValue[@key = 
>> $keyName-parent-toc-info]]' is removed from document in database
>>
>> But if I try to do it in the following script (the real script), it does not 
>> work:
>> 1- I populate a map $mapA with ids of eligible documents based on a 
>> sem:sparql query using a sem:store constructor
>> 2- I populate a map $mapB with ids of larger set of documents based on a 
>> sem:sparql query using a sem:store constructor with a 
>> cts:element-attribute-value-query on the element to be deleted 
>> (cts:element-attribute-value-query 
&

Re: [MarkLogic Dev General] Strange issue with xdmp:node-delete

2018-01-31 Thread Lanz
yes Florent, it returns the doc uri

On Wed, Jan 31, 2018 at 6:53 PM, Florent Georges  wrote:

> Just in case, you can confirm that the node you are about to delete is
> indeed from a stored document with something like the following :
>
> xdmp:log(fn:document-uri(fn:root($node)))
>
> --
> Florent Georges
> H2O Consulting
> http://h2o.consulting/
>
> On 31 Jan 2018 18:47, "Lanz"  wrote:
>
>> Hi Mister Florent,
>>
>> Thks for your answer.
>> There is no symptom at all: no exception, no specific log, no deletion.
>> When I run the 'real' script on QConsole (or Oxygen connected through xdbc
>> to ML), it returns the focus after a while (whitout SVC-EXTIME) without any
>> deletion.
>> I'm trying with a colleague to simplify the script and recreate a
>> readable case for everyone.
>> For now it seems that the sem:sparql combined with sem:store has some
>> influences on this behavior
>>
>> So I will come back soon with a simplified script.
>> Lanz
>>
>>
>> On Wed, Jan 31, 2018 at 6:26 PM, Florent Georges 
>> wrote:
>> >
>> > Salut Lancelot,
>> >
>> > I might have missed it, but what is the exact symptom? Any error
>> message? Have you tried the "real" script through QConsole? Any chance you
>> simplify it and post it here? More pairs of eyes might catch something you
>> missed...
>> >
>> > Regards,
>> >
>> > --
>> > Florent Georges
>> > H2O Consulting
>> > http://h2o.consulting/
>> >
>> > On 30 Jan 2018 22:29, "Lanz"  wrote:
>> >>
>> >> Hi all,
>> >>
>> >> I've got this strange issue with xdmp:node-delete with a node in the
>> database with Marklogic 8.0-6.3.
>> >> First when I use xdmp:node-delete on the target node with the above
>> basic script, it works:
>> >> 
>> 
>> >> xquery version "1.0-ml";
>> >> declare namespace html = "http://www.w3.org/1999/xhtml";;
>> >> declare namespace l="http://www.oecd.org/ns/lambda/schema/";;
>> >> import module namespace db = "http://www.oecd.org/ns/lambda/app/lib/db";
>> at "/app/lib/db/db.xqm";
>> >> import module namespace exportlib = "http://www.oecd.org/ns/lambda
>> /app/lib/export" at "/app/lib/export/export.xqm";
>> >> declare variable $keyName-parent-toc-info as xs:string :=
>> 'parent-toc-info';
>> >> let $rid := 'urn:oecd.org:publications:id:expression:g2g12781'
>> >> let $doc := fn:doc(db:get-uri-by-rid($rid))/l:expression
>> >> return
>> >> (
>> >> (: display parent node before child node deletion :)
>> >> $doc/l:exportChannels/l:exportChannel[@href =
>> $exportlib:channel-rid-i2])/l:precomputedValues
>> >> ,xdmp:node-delete($doc/l:exportChannels/l:exportChannel[@href =
>> $exportlib:channel-rid-i2])/l:precomputedValues/l:precomputedValue[@key
>> = $keyName-parent-toc-info]
>> >> )
>> >> 
>> 
>> >> The node 'l:precomputedValues[l:precomputedValue[@key =
>> $keyName-parent-toc-info]]' is removed from document in database
>> >>
>> >> But if I try to do it in the following script (the real script), it
>> does not work:
>> >> 1- I populate a map $mapA with ids of eligible documents based on a
>> sem:sparql query using a sem:store constructor
>> >> 2- I populate a map $mapB with ids of larger set of documents based on
>> a sem:sparql query using a sem:store constructor with a
>> cts:element-attribute-value-query on the element to be deleted
>> (cts:element-attribute-value-query 
>> (xs:QName('l:precomputedValue'),xs:QName('key'),
>> $keyName-parent-toc-info)) among other cts:query constructor
>> >> 3- Then I create a 3rd map based on the difference of the two maps
>> ($mapB - $mapA)
>> >> 4- I loop over this map of ids to get the uri of the document, then
>> the document with fn:doc(), then I get the element l:precomputedValues to
>> be deleted with an Xpath (the same as in the basic script)
>> >> 5- It never works on Oxygen using an xdbc connection on ML db or event
>> in Qconsole. There is no error, it takes a while and I've got nothing in
>> the error log (even with the finest setting). When I launch the profiler on
>> Qconsole, here the message I get at the end :
>> >> [1.0-ml] XDMP-CAST: (err:FORG0001) xs:unsignedLong($d div
>> xs:dayTimeDuration("PT0.01S")) -- Invalid cast: -178609914.9 cast as
>> xs:unsignedLong
>> >>
>> >> I confirm:
>> >> - the node to be deleted is in the db not an on-the-fly constructed
>> node
>> >> - the id used in the first successful script comes from the final map
>> in second script. This final map is populated with correct and real
>> document ids.
>> >>
>> >> Any help is appreciated
>> >> Lanz
>> >>
>> >> ___
>> >> General mailing list
>> >> General@developer.marklogic.com
>> >> Manage your subscription at:
>> >> http://developer.marklogic.com/mailman/listinfo/general
>> >>
>> >
>> > ___
>> > General mailing list
>> > General@developer.marklogic.com
>> > Manage your subscription at:
>> > http://develo

Re: [MarkLogic Dev General] Strange issue with xdmp:node-delete

2018-01-31 Thread Florent Georges
Just in case, you can confirm that the node you are about to delete is
indeed from a stored document with something like the following :

xdmp:log(fn:document-uri(fn:root($node)))

-- 
Florent Georges
H2O Consulting
http://h2o.consulting/

On 31 Jan 2018 18:47, "Lanz"  wrote:

> Hi Mister Florent,
>
> Thks for your answer.
> There is no symptom at all: no exception, no specific log, no deletion.
> When I run the 'real' script on QConsole (or Oxygen connected through xdbc
> to ML), it returns the focus after a while (whitout SVC-EXTIME) without any
> deletion.
> I'm trying with a colleague to simplify the script and recreate a readable
> case for everyone.
> For now it seems that the sem:sparql combined with sem:store has some
> influences on this behavior
>
> So I will come back soon with a simplified script.
> Lanz
>
>
> On Wed, Jan 31, 2018 at 6:26 PM, Florent Georges 
> wrote:
> >
> > Salut Lancelot,
> >
> > I might have missed it, but what is the exact symptom? Any error
> message? Have you tried the "real" script through QConsole? Any chance you
> simplify it and post it here? More pairs of eyes might catch something you
> missed...
> >
> > Regards,
> >
> > --
> > Florent Georges
> > H2O Consulting
> > http://h2o.consulting/
> >
> > On 30 Jan 2018 22:29, "Lanz"  wrote:
> >>
> >> Hi all,
> >>
> >> I've got this strange issue with xdmp:node-delete with a node in the
> database with Marklogic 8.0-6.3.
> >> First when I use xdmp:node-delete on the target node with the above
> basic script, it works:
> >> 
> 
> >> xquery version "1.0-ml";
> >> declare namespace html = "http://www.w3.org/1999/xhtml";;
> >> declare namespace l="http://www.oecd.org/ns/lambda/schema/";;
> >> import module namespace db = "http://www.oecd.org/ns/lambda/app/lib/db";
> at "/app/lib/db/db.xqm";
> >> import module namespace exportlib = "http://www.oecd.org/ns/lambda
> /app/lib/export" at "/app/lib/export/export.xqm";
> >> declare variable $keyName-parent-toc-info as xs:string :=
> 'parent-toc-info';
> >> let $rid := 'urn:oecd.org:publications:id:expression:g2g12781'
> >> let $doc := fn:doc(db:get-uri-by-rid($rid))/l:expression
> >> return
> >> (
> >> (: display parent node before child node deletion :)
> >> $doc/l:exportChannels/l:exportChannel[@href =
> $exportlib:channel-rid-i2])/l:precomputedValues
> >> ,xdmp:node-delete($doc/l:exportChannels/l:exportChannel[@href =
> $exportlib:channel-rid-i2])/l:precomputedValues/l:precomputedValue[@key =
> $keyName-parent-toc-info]
> >> )
> >> 
> 
> >> The node 'l:precomputedValues[l:precomputedValue[@key =
> $keyName-parent-toc-info]]' is removed from document in database
> >>
> >> But if I try to do it in the following script (the real script), it
> does not work:
> >> 1- I populate a map $mapA with ids of eligible documents based on a
> sem:sparql query using a sem:store constructor
> >> 2- I populate a map $mapB with ids of larger set of documents based on
> a sem:sparql query using a sem:store constructor with a
> cts:element-attribute-value-query on the element to be deleted
> (cts:element-attribute-value-query 
> (xs:QName('l:precomputedValue'),xs:QName('key'),
> $keyName-parent-toc-info)) among other cts:query constructor
> >> 3- Then I create a 3rd map based on the difference of the two maps
> ($mapB - $mapA)
> >> 4- I loop over this map of ids to get the uri of the document, then the
> document with fn:doc(), then I get the element l:precomputedValues to be
> deleted with an Xpath (the same as in the basic script)
> >> 5- It never works on Oxygen using an xdbc connection on ML db or event
> in Qconsole. There is no error, it takes a while and I've got nothing in
> the error log (even with the finest setting). When I launch the profiler on
> Qconsole, here the message I get at the end :
> >> [1.0-ml] XDMP-CAST: (err:FORG0001) xs:unsignedLong($d div
> xs:dayTimeDuration("PT0.01S")) -- Invalid cast: -178609914.9 cast as
> xs:unsignedLong
> >>
> >> I confirm:
> >> - the node to be deleted is in the db not an on-the-fly constructed node
> >> - the id used in the first successful script comes from the final map
> in second script. This final map is populated with correct and real
> document ids.
> >>
> >> Any help is appreciated
> >> Lanz
> >>
> >> ___
> >> General mailing list
> >> General@developer.marklogic.com
> >> Manage your subscription at:
> >> http://developer.marklogic.com/mailman/listinfo/general
> >>
> >
> > ___
> > General mailing list
> > General@developer.marklogic.com
> > Manage your subscription at:
> > http://developer.marklogic.com/mailman/listinfo/general
> >
>
> ___
> General mailing list
> General@developer.marklogic.com
> Manage your subscription at:
> http://developer.marklogic.com/mailman/l

Re: [MarkLogic Dev General] Strange issue with xdmp:node-delete

2018-01-31 Thread Lanz
Hi Mister Florent,

Thks for your answer.
There is no symptom at all: no exception, no specific log, no deletion.
When I run the 'real' script on QConsole (or Oxygen connected through xdbc
to ML), it returns the focus after a while (whitout SVC-EXTIME) without any
deletion.
I'm trying with a colleague to simplify the script and recreate a readable
case for everyone.
For now it seems that the sem:sparql combined with sem:store has some
influences on this behavior

So I will come back soon with a simplified script.
Lanz


On Wed, Jan 31, 2018 at 6:26 PM, Florent Georges  wrote:
>
> Salut Lancelot,
>
> I might have missed it, but what is the exact symptom? Any error message?
Have you tried the "real" script through QConsole? Any chance you simplify
it and post it here? More pairs of eyes might catch something you missed...
>
> Regards,
>
> --
> Florent Georges
> H2O Consulting
> http://h2o.consulting/
>
> On 30 Jan 2018 22:29, "Lanz"  wrote:
>>
>> Hi all,
>>
>> I've got this strange issue with xdmp:node-delete with a node in the
database with Marklogic 8.0-6.3.
>> First when I use xdmp:node-delete on the target node with the above
basic script, it works:
>> 
>> xquery version "1.0-ml";
>> declare namespace html = "http://www.w3.org/1999/xhtml";;
>> declare namespace l="http://www.oecd.org/ns/lambda/schema/";;
>> import module namespace db = "http://www.oecd.org/ns/lambda/app/lib/db";
at "/app/lib/db/db.xqm";
>> import module namespace exportlib = "http://www.oecd.org/ns/
lambda/app/lib/export" at "/app/lib/export/export.xqm";
>> declare variable $keyName-parent-toc-info as xs:string :=
'parent-toc-info';
>> let $rid := 'urn:oecd.org:publications:id:expression:g2g12781'
>> let $doc := fn:doc(db:get-uri-by-rid($rid))/l:expression
>> return
>> (
>> (: display parent node before child node deletion :)
>> $doc/l:exportChannels/l:exportChannel[@href =
$exportlib:channel-rid-i2])/l:precomputedValues
>> ,xdmp:node-delete($doc/l:exportChannels/l:exportChannel[@href =
$exportlib:channel-rid-i2])/l:precomputedValues/l:precomputedValue[@key =
$keyName-parent-toc-info]
>> )
>> 
>> The node 'l:precomputedValues[l:precomputedValue[@key =
$keyName-parent-toc-info]]' is removed from document in database
>>
>> But if I try to do it in the following script (the real script), it does
not work:
>> 1- I populate a map $mapA with ids of eligible documents based on a
sem:sparql query using a sem:store constructor
>> 2- I populate a map $mapB with ids of larger set of documents based on a
sem:sparql query using a sem:store constructor with a
cts:element-attribute-value-query on the element to be deleted
(cts:element-attribute-value-query
(xs:QName('l:precomputedValue'),xs:QName('key'),
$keyName-parent-toc-info)) among other cts:query constructor
>> 3- Then I create a 3rd map based on the difference of the two maps
($mapB - $mapA)
>> 4- I loop over this map of ids to get the uri of the document, then the
document with fn:doc(), then I get the element l:precomputedValues to be
deleted with an Xpath (the same as in the basic script)
>> 5- It never works on Oxygen using an xdbc connection on ML db or event
in Qconsole. There is no error, it takes a while and I've got nothing in
the error log (even with the finest setting). When I launch the profiler on
Qconsole, here the message I get at the end :
>> [1.0-ml] XDMP-CAST: (err:FORG0001) xs:unsignedLong($d div
xs:dayTimeDuration("PT0.01S")) -- Invalid cast: -178609914.9 cast as
xs:unsignedLong
>>
>> I confirm:
>> - the node to be deleted is in the db not an on-the-fly constructed node
>> - the id used in the first successful script comes from the final map in
second script. This final map is populated with correct and real document
ids.
>>
>> Any help is appreciated
>> Lanz
>>
>> ___
>> General mailing list
>> General@developer.marklogic.com
>> Manage your subscription at:
>> http://developer.marklogic.com/mailman/listinfo/general
>>
>
> ___
> General mailing list
> General@developer.marklogic.com
> Manage your subscription at:
> http://developer.marklogic.com/mailman/listinfo/general
>
___
General mailing list
General@developer.marklogic.com
Manage your subscription at: 
http://developer.marklogic.com/mailman/listinfo/general


Re: [MarkLogic Dev General] Strange issue with xdmp:node-delete

2018-01-31 Thread Florent Georges
Salut Lancelot,

I might have missed it, but what is the exact symptom? Any error message?
Have you tried the "real" script through QConsole? Any chance you simplify
it and post it here? More pairs of eyes might catch something you missed...

Regards,

-- 
Florent Georges
H2O Consulting
http://h2o.consulting/

On 30 Jan 2018 22:29, "Lanz"  wrote:

> Hi all,
>
> I've got this strange issue with xdmp:node-delete with a node in the
> database with Marklogic 8.0-6.3.
> First when I use xdmp:node-delete on the target node with the above basic
> script, it works:
> 
> xquery version "1.0-ml";
> declare namespace html = "http://www.w3.org/1999/xhtml";;
> declare namespace l="http://www.oecd.org/ns/lambda/schema/";;
> import module namespace db = "http://www.oecd.org/ns/lambda/app/lib/db";
> at "/app/lib/db/db.xqm";
> import module namespace exportlib = "http://www.oecd.org/ns/
> lambda/app/lib/export" at "/app/lib/export/export.xqm";
> declare variable $keyName-parent-toc-info as xs:string :=
> 'parent-toc-info';
> let $rid := 'urn:oecd.org:publications:id:expression:g2g12781'
> let $doc := fn:doc(db:get-uri-by-rid($rid))/l:expression
> return
> (
> (: display parent node before child node deletion :)
> $doc/l:exportChannels/l:exportChannel[@href =
> $exportlib:channel-rid-i2])/l:precomputedValues
> ,xdmp:node-delete($doc/l:exportChannels/l:exportChannel[@href =
> $exportlib:channel-rid-i2])/l:precomputedValues/l:precomputedValue[@key =
> $keyName-parent-toc-info]
> )
> 
> The node 'l:precomputedValues[l:precomputedValue[@key =
> $keyName-parent-toc-info]]' is removed from document in database
>
> But if I try to do it in the following script (the real script), it does
> not work:
> 1- I populate a map $mapA with ids of eligible documents based on a
> sem:sparql query using a sem:store constructor
> 2- I populate a map $mapB with ids of larger set of documents based on a
> sem:sparql query using a sem:store constructor with a
> cts:element-attribute-value-query on the element to be deleted
> (cts:element-attribute-value-query 
> (xs:QName('l:precomputedValue'),xs:QName('key'),
> $keyName-parent-toc-info)) among other cts:query constructor
> 3- Then I create a 3rd map based on the difference of the two maps ($mapB
> - $mapA)
> 4- I loop over this map of ids to get the uri of the document, then the
> document with fn:doc(), then I get the element l:precomputedValues to be
> deleted with an Xpath (the same as in the basic script)
> 5- It never works on Oxygen using an xdbc connection on ML db or event in
> Qconsole. There is no error, it takes a while and I've got nothing in the
> error log (even with the finest setting). When I launch the profiler on
> Qconsole, here the message I get at the end :
> [1.0-ml] XDMP-CAST: (err:FORG0001) xs:unsignedLong($d div
> xs:dayTimeDuration("PT0.01S")) -- Invalid cast: -178609914.9 cast as
> xs:unsignedLong
>
> I confirm:
> - the node to be deleted is in the db not an on-the-fly constructed node
> - the id used in the first successful script comes from the final map in
> second script. This final map is populated with correct and real document
> ids.
>
> Any help is appreciated
> Lanz
>
> ___
> General mailing list
> General@developer.marklogic.com
> Manage your subscription at:
> http://developer.marklogic.com/mailman/listinfo/general
>
>
___
General mailing list
General@developer.marklogic.com
Manage your subscription at: 
http://developer.marklogic.com/mailman/listinfo/general