Re: [MarkLogic Dev General] Exit query without writing to error log?

2018-01-24 Thread Justin Makeig
If not, we will probably need to restructure the queries to not throw an XQuery 
error at all and just send the appropriate response code and error message. 
Darn, oh well.

As the docs for fn:error() say, the expected behavior when throwing an error is 
to stop the execution, rollback any inflight transactions, and immediately 
return. try/catch can capture (most) errors, but parameter validation sounds 
more like regular program flow than a fatal error condition. Given the 
documented behavior of thrown errors, I’d assert the logging to the error log 
is the correct and expected default behavior. Is there a way you could refactor 
to not throw errors, but return something like a boolean or a status code (that 
you could translate to an HTTP status code on the way out)?

Justin

On Jan 24, 2018, at 10:54 PM, David Ennis 
> wrote:

HI Evan,

Hmm. I just did the same test and was surprised. But yes, still logging the 
error seems to match the documentation.. Sorry about that. My only other 
suggestion is: Is there any common code used as some sort of standard 
invoker/router to the rest of your code? If so, that may be the best place to 
put a tray catch and let the rest bubble up to that point.

Regards,
David

--


From: 
>
 on behalf of Evan Lenz >
Reply-To: MarkLogic Developer Discussion 
>
Date: Thursday, January 25, 2018 at 1:43 AM
To: MarkLogic Developer Discussion 
>
Subject: Re: [MarkLogic Dev General] Exit query without writing to error log?

Hi David,

Following up on this. I tried the custom error handler, and it appears that the 
errors are not actually caught but just forwarded to the error-handler XQuery. 
The impact of this for me (and which is what I'm trying to address) is that the 
errors are still written to the error log, regardless of whether they are 
handled by a custom error handler. Does this accord with your understanding of 
how it's supposed to work?

Do you have any other ideas for how to prevent the writing to the error log? If 
not, we will probably need to restructure the queries to not throw an XQuery 
error at all and just send the appropriate response code and error message. 
Darn, oh well.

Thanks,
Evan

On Wed, Jan 24, 2018 at 2:45 PM, Evan Lenz 
> wrote:
Thanks, guys. David, the custom error handler is a great idea. I had forgotten 
about this option. We're not currently using it but definitely will soon. It 
will help us move forward without fundamentally changing the structure of many 
queries. It will enable us to wrap a virtual try/catch around everything 
without having to change the code itself. Very helpful!

Thanks again,
Evan


On Wed, Jan 24, 2018 at 4:57 AM, David Ennis 
> wrote:
HI.

Further to Florent’s comment, assuming your code is OK with the error bubbling 
up to the top, you can catch them all in a single place and act accordingly  
using a custom error handler. Using this in conjunction with throwing your own 
errors (and handling the code in the top-level handler) can be useful.

https://docs.marklogic.com/guide/app-dev/appserver-control#id_89735

Regards,
David

--


From: 
>
 on behalf of Florent Georges >
Reply-To: MarkLogic Developer Discussion 
>
Date: Wednesday, January 24, 2018 at 1:53 PM
To: MarkLogic Developer Discussion 
>
Subject: Re: [MarkLogic Dev General] Exit query without writing to error log?

Hi Evan,

The error is logged only if it "reaches the top", that is, if it is not caught.

If the error shouldn't behave as such, can't you just catch it before? (and 
yes, potentially return wathever HTTP response you deem appropriate).

Regards,

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


On 24 January 2018 at 03:22, Evan Lenz wrote:
Hello,

My client has XQuery parameter-validation code which calls the error() function 
when invalid parameters are supplied. This event gets written to the error log. 
Is there a way to prevent this?

I recognize the best practice is to return a more appropriate HTTP response 
code (than 500) when handling invalid input. I also recognize this is anathema 
to FP. But my question still stands:

Is there a way to interrupt/exit a query without triggering an Error-level log 
message?

Thanks,

Evan Lenz
President, Lenz Consulting Group, Inc.

Re: [MarkLogic Dev General] Exit query without writing to error log?

2018-01-24 Thread David Ennis
HI Evan,

Hmm. I just did the same test and was surprised. But yes, still logging the 
error seems to match the documentation.. Sorry about that. My only other 
suggestion is: Is there any common code used as some sort of standard 
invoker/router to the rest of your code? If so, that may be the best place to 
put a tray catch and let the rest bubble up to that point.

Regards,
David

--


From:  on behalf of Evan Lenz 

Reply-To: MarkLogic Developer Discussion 
Date: Thursday, January 25, 2018 at 1:43 AM
To: MarkLogic Developer Discussion 
Subject: Re: [MarkLogic Dev General] Exit query without writing to error log?

Hi David,

Following up on this. I tried the custom error handler, and it appears that the 
errors are not actually caught but just forwarded to the error-handler XQuery. 
The impact of this for me (and which is what I'm trying to address) is that the 
errors are still written to the error log, regardless of whether they are 
handled by a custom error handler. Does this accord with your understanding of 
how it's supposed to work?

Do you have any other ideas for how to prevent the writing to the error log? If 
not, we will probably need to restructure the queries to not throw an XQuery 
error at all and just send the appropriate response code and error message. 
Darn, oh well.

Thanks,
Evan

On Wed, Jan 24, 2018 at 2:45 PM, Evan Lenz 
> wrote:
Thanks, guys. David, the custom error handler is a great idea. I had forgotten 
about this option. We're not currently using it but definitely will soon. It 
will help us move forward without fundamentally changing the structure of many 
queries. It will enable us to wrap a virtual try/catch around everything 
without having to change the code itself. Very helpful!

Thanks again,
Evan


On Wed, Jan 24, 2018 at 4:57 AM, David Ennis 
> wrote:
HI.

Further to Florent’s comment, assuming your code is OK with the error bubbling 
up to the top, you can catch them all in a single place and act accordingly  
using a custom error handler. Using this in conjunction with throwing your own 
errors (and handling the code in the top-level handler) can be useful.

https://docs.marklogic.com/guide/app-dev/appserver-control#id_89735

Regards,
David

--


From: 
>
 on behalf of Florent Georges >
Reply-To: MarkLogic Developer Discussion 
>
Date: Wednesday, January 24, 2018 at 1:53 PM
To: MarkLogic Developer Discussion 
>
Subject: Re: [MarkLogic Dev General] Exit query without writing to error log?

Hi Evan,

The error is logged only if it "reaches the top", that is, if it is not caught.

If the error shouldn't behave as such, can't you just catch it before? (and 
yes, potentially return wathever HTTP response you deem appropriate).

Regards,

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


On 24 January 2018 at 03:22, Evan Lenz wrote:
Hello,

My client has XQuery parameter-validation code which calls the error() function 
when invalid parameters are supplied. This event gets written to the error log. 
Is there a way to prevent this?

I recognize the best practice is to return a more appropriate HTTP response 
code (than 500) when handling invalid input. I also recognize this is anathema 
to FP. But my question still stands:

Is there a way to interrupt/exit a query without triggering an Error-level log 
message?

Thanks,

Evan Lenz
President, Lenz Consulting Group, Inc.
http://lenzconsulting.com

___
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] question about transactions

2018-01-24 Thread Geert Josten
The outer query runs in query mode, so runs against the timestamp of initial 
invocation, causing it to never see the result of sem:rdf-insert. You’d have to 
put the sem:sparql in an xdmp:eval with different-transaction as well.

I also wonder though: what are you trying to do, why trying to squeeze insert 
and read in one request?

Cheers,
Geert

From: 
>
 on behalf of David Ennis 
>
Reply-To: MarkLogic Developer Discussion 
>
Date: Wednesday, January 24, 2018 at 7:34 PM
To: MarkLogic Developer Discussion 
>
Subject: Re: [MarkLogic Dev General] question about transactions

Please look up the options for xdmp:eval and note the following options 
explained there:
- transaction-mode
- isolation

Then change your eval to have the following options:
- transaction-mode=update-auto-commit
- isolation = different transaction

Then move the sem:sparql statement below the eval in your main code.

What are you doing here?

You are telling the insert to run as a separate transaction and auto-commit. 
This makes the triples available immediately after the eval is done. Therefore, 
you should run the select in the main code and not the isolated transaction.

Careful with the use of different transactions via eval and invoke. The wrong 
combination can get you into a deadlock.

Regards,
David Ennis

--


From: 
>
 on behalf of Erik Zander 
>
Reply-To: MarkLogic Developer Discussion 
>
Date: Wednesday, January 24, 2018 at 5:35 PM
To: MarkLogic Developer Discussion 
>
Subject: [MarkLogic Dev General] question about transactions

Hi All,

I have a question about I think transactions.

I want to insert some rdf and then query the database, and I want to do this in 
a function so I can call the function and depending on if I have the data in 
Marklogic or not get the data as rdf and insert it.

But my problem is that the following code only returns result second time I 
call it.
I’m thankful for pointers here
Regards
Erik
Code below
==

xquery version "1.0-ml"encoding "utf-8";


import module namespace sem="http://marklogic.com/semantics;
  at"/MarkLogic/semantics.xqy";
declare namespace rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#;;

let $wDataRdf:=
http://www.w3.org/1999/02/22-rdf-syntax-ns#;
  xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#;

  xmlns:wikibase="http://wikiba.se/ontology#;
  xmlns:wd="http://www.wikidata.org/entity/;
  >

Re: [MarkLogic Dev General] Exit query without writing to error log?

2018-01-24 Thread Evan Lenz
Hi David,

Following up on this. I tried the custom error handler, and it appears that
the errors are not actually caught but just forwarded to the error-handler
XQuery. The impact of this for me (and which is what I'm trying to address)
is that the errors are still written to the error log, regardless of
whether they are handled by a custom error handler. Does this accord with
your understanding of how it's supposed to work?

Do you have any other ideas for how to prevent the writing to the error
log? If not, we will probably need to restructure the queries to not throw
an XQuery error at all and just send the appropriate response code and
error message. Darn, oh well.

Thanks,
Evan

On Wed, Jan 24, 2018 at 2:45 PM, Evan Lenz  wrote:

> Thanks, guys. David, the custom error handler is a great idea. I had
> forgotten about this option. We're not currently using it but definitely
> will soon. It will help us move forward without fundamentally changing the
> structure of many queries. It will enable us to wrap a virtual try/catch
> around everything without having to change the code itself. Very helpful!
>
> Thanks again,
> Evan
>
>
> On Wed, Jan 24, 2018 at 4:57 AM, David Ennis 
> wrote:
>
>> HI.
>>
>>
>>
>> Further to Florent’s comment, assuming your code is OK with the error
>> bubbling up to the top, you can catch them all in a single place and act
>> accordingly  using a custom error handler. Using this in conjunction with
>> throwing your own errors (and handling the code in the top-level handler)
>> can be useful.
>>
>>
>>
>> https://docs.marklogic.com/guide/app-dev/appserver-control#id_89735
>>
>>
>>
>> Regards,
>>
>> David
>>
>>
>>
>> --
>>
>>
>>
>>
>>
>> *From: * on behalf of Florent
>> Georges 
>> *Reply-To: *MarkLogic Developer Discussion > om>
>> *Date: *Wednesday, January 24, 2018 at 1:53 PM
>> *To: *MarkLogic Developer Discussion 
>> *Subject: *Re: [MarkLogic Dev General] Exit query without writing to
>> error log?
>>
>>
>>
>> Hi Evan,
>>
>>
>>
>> The error is logged only if it "reaches the top", that is, if it is not
>> caught.
>>
>>
>>
>> If the error shouldn't behave as such, can't you just catch it before?
>> (and yes, potentially return wathever HTTP response you deem appropriate).
>>
>>
>>
>> Regards,
>>
>>
>>
>> --
>>
>> Florent Georges
>>
>> H2O Consulting
>>
>> http://h2o.consulting/
>>
>>
>>
>>
>>
>> On 24 January 2018 at 03:22, Evan Lenz wrote:
>>
>> Hello,
>>
>>
>>
>> My client has XQuery parameter-validation code which calls the error()
>> function when invalid parameters are supplied. This event gets written to
>> the error log. Is there a way to prevent this?
>>
>>
>>
>> I recognize the best practice is to return a more appropriate HTTP
>> response code (than 500) when handling invalid input. I also recognize this
>> is anathema to FP. But my question still stands:
>>
>>
>>
>> Is there a way to interrupt/exit a query without triggering an
>> Error-level log message?
>>
>>
>>
>> Thanks,
>>
>> Evan Lenz
>> President, Lenz Consulting Group, Inc.
>> http://lenzconsulting.com
>>
>>
>> ___
>> 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] Exit query without writing to error log?

2018-01-24 Thread Evan Lenz
Thanks, guys. David, the custom error handler is a great idea. I had
forgotten about this option. We're not currently using it but definitely
will soon. It will help us move forward without fundamentally changing the
structure of many queries. It will enable us to wrap a virtual try/catch
around everything without having to change the code itself. Very helpful!

Thanks again,
Evan


On Wed, Jan 24, 2018 at 4:57 AM, David Ennis 
wrote:

> HI.
>
>
>
> Further to Florent’s comment, assuming your code is OK with the error
> bubbling up to the top, you can catch them all in a single place and act
> accordingly  using a custom error handler. Using this in conjunction with
> throwing your own errors (and handling the code in the top-level handler)
> can be useful.
>
>
>
> https://docs.marklogic.com/guide/app-dev/appserver-control#id_89735
>
>
>
> Regards,
>
> David
>
>
>
> --
>
>
>
>
>
> *From: * on behalf of Florent
> Georges 
> *Reply-To: *MarkLogic Developer Discussion  com>
> *Date: *Wednesday, January 24, 2018 at 1:53 PM
> *To: *MarkLogic Developer Discussion 
> *Subject: *Re: [MarkLogic Dev General] Exit query without writing to
> error log?
>
>
>
> Hi Evan,
>
>
>
> The error is logged only if it "reaches the top", that is, if it is not
> caught.
>
>
>
> If the error shouldn't behave as such, can't you just catch it before?
> (and yes, potentially return wathever HTTP response you deem appropriate).
>
>
>
> Regards,
>
>
>
> --
>
> Florent Georges
>
> H2O Consulting
>
> http://h2o.consulting/
>
>
>
>
>
> On 24 January 2018 at 03:22, Evan Lenz wrote:
>
> Hello,
>
>
>
> My client has XQuery parameter-validation code which calls the error()
> function when invalid parameters are supplied. This event gets written to
> the error log. Is there a way to prevent this?
>
>
>
> I recognize the best practice is to return a more appropriate HTTP
> response code (than 500) when handling invalid input. I also recognize this
> is anathema to FP. But my question still stands:
>
>
>
> Is there a way to interrupt/exit a query without triggering an Error-level
> log message?
>
>
>
> Thanks,
>
> Evan Lenz
> President, Lenz Consulting Group, Inc.
> http://lenzconsulting.com
>
>
> ___
> 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] (no subject)

2018-01-24 Thread Justin Makeig
You’re trying to update all of the documents in the “input” collection in a 
single transaction, the default scope of a JavaScript module. For small numbers 
of documents (hundreds or thousands) that will work. For large or unknown 
numbers of documents that will generally overwhelm some resource. In your case, 
you’ve blown out your expanded tree cache. Your best bet is to break the 
transformation into multiple transactions and spread those out over multiple 
hosts in a cluster. The MarkLogic Data Movement SDK is designed for exactly 
such workloads. Take a look at the docs 
 for more 
information on how to orchestrate a bulk transformation from Java.

Justin

--
Justin Makeig
Senior Director, Product Management
MarkLogic
jmak...@marklogic.com

On Jan 24, 2018, at 10:19 AM, C. Yaswanth 
> wrote:

Hi All,

Actually i have a set of json files(i.e.Total : 1M with Size 500MB). Each json 
file has 18 Keys. I tried to implement Envelope pattern using below Javascript

'use strict';
declareUpdate()
var docs = fn.collection("input");
for(var doc of docs) {
  var transformed = {};

  transformed.Metadata = { "Last Used" : ""};
  transformed.Updated = { "University" : "UCLA"}
  transformed.Source = doc; //Sending original data under Source section
  xdmp.nodeReplace(doc,transformed)
}

I tried invoking this `JS.sjs` using JAVA API of marklogic 9. But i encountered 
below error :

Exception in thread "main" com.marklogic.client.FailedRequestException: 
Local message: failed to apply resource at invoke: Internal Server Error. 
Server Message: XDMP-EXPNTREECACHEFULL: for(var doc of docs) { -- Expanded tree 
cache full on host localhost uri file.json-0-968991
 at 
com.marklogic.client.impl.OkHttpServices.checkStatus(OkHttpServices.java:4317)
 at 
com.marklogic.client.impl.OkHttpServices.postIteratedResourceImpl(OkHttpServices.java:3831)
 at 
com.marklogic.client.impl.OkHttpServices.postEvalInvoke(OkHttpServices.java:3768)
 at 
com.marklogic.client.impl.ServerEvaluationCallImpl.eval(ServerEvaluationCallImpl.java:164)
 at 
com.marklogic.client.impl.ServerEvaluationCallImpl.eval(ServerEvaluationCallImpl.java:153)
 at 
com.marklogic.client.impl.ServerEvaluationCallImpl.evalAs(ServerEvaluationCallImpl.java:144)
 at bulkimport.Tsm.main(Tsm.java:19)

I went through documentation 
(i.e.https://help.marklogic.com/knowledgebase/article/View/9/16/resolving-xdmp-expntreecachefull-errors)
  where they had mentioned ways to resolve this error. Following that i had 
increased `expanded tree cache size*` to `2048` but still i am facing same 
error.

How can i optimize by above code (i.e.`JS.sjs`) to avoid this error ?

Any help is appreciated.
___
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] question about transactions

2018-01-24 Thread David Ennis
Please look up the options for xdmp:eval and note the following options 
explained there:
- transaction-mode
- isolation

Then change your eval to have the following options:
- transaction-mode=update-auto-commit
- isolation = different transaction

Then move the sem:sparql statement below the eval in your main code.

What are you doing here?

You are telling the insert to run as a separate transaction and auto-commit. 
This makes the triples available immediately after the eval is done. Therefore, 
you should run the select in the main code and not the isolated transaction.

Careful with the use of different transactions via eval and invoke. The wrong 
combination can get you into a deadlock.

Regards,
David Ennis

--


From:  on behalf of Erik Zander 

Reply-To: MarkLogic Developer Discussion 
Date: Wednesday, January 24, 2018 at 5:35 PM
To: MarkLogic Developer Discussion 
Subject: [MarkLogic Dev General] question about transactions

Hi All,

I have a question about I think transactions.

I want to insert some rdf and then query the database, and I want to do this in 
a function so I can call the function and depending on if I have the data in 
Marklogic or not get the data as rdf and insert it.

But my problem is that the following code only returns result second time I 
call it.
I’m thankful for pointers here
Regards
Erik
Code below
==

xquery version "1.0-ml" encoding "utf-8";


import module namespace sem = "http://marklogic.com/semantics;
  at "/MarkLogic/semantics.xqy";
declare namespace rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#;;

let $wDataRdf :=
http://www.w3.org/1999/02/22-rdf-syntax-ns#;
  xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#;

  xmlns:wikibase="http://wikiba.se/ontology#;
  xmlns:wd="http://www.wikidata.org/entity/;
  >
http://www.wikidata.org/entity/Q925hhq;>
mup



let $insert :=  xdmp:eval(
'
import module namespace sem = "http://marklogic.com/semantics;
  at "/MarkLogic/semantics.xqy";
declare variable $wDataRdf as node() external;
sem:rdf-insert(sem:rdf-parse($wDataRdf,("rdfxml", 
"graph=http://www.wikidata.org;)))'
,(xs:QName("wDataRdf"), $wDataRdf)
)
return sem:sparql('
PREFIX wd: 
PREFIX rdfs: 
SELECT ?label WHERE {
   wd:Q925hhq  rdfs:label ?label
   FILTER (langMatches( lang(?label), "SV" ) )
}'
)




___
General mailing list
General@developer.marklogic.com
Manage your subscription at: 
http://developer.marklogic.com/mailman/listinfo/general


[MarkLogic Dev General] (no subject)

2018-01-24 Thread C. Yaswanth
Hi All,

Actually i have a set of json files(i.e.Total : 1M with Size 500MB). Each
json file has 18 Keys. I tried to implement Envelope pattern using below
Javascript

'use strict';
declareUpdate()
var docs = fn.collection("input");
for(var doc of docs) {
  var transformed = {};

  transformed.Metadata = { "Last Used" : ""};
  transformed.Updated = { "University" : "UCLA"}
  transformed.Source = doc; //Sending original data under Source section
  xdmp.nodeReplace(doc,transformed)
}

I tried invoking this `JS.sjs` using JAVA API of marklogic 9. But i
encountered below error :

Exception in thread "main" com.marklogic.client.FailedRequestException:
Local message: failed to apply resource at invoke: Internal Server Error.
Server Message: XDMP-EXPNTREECACHEFULL: for(var doc of docs) { -- Expanded
tree cache full on host localhost uri file.json-0-968991
 at com.marklogic.client.impl.OkHttpServices.checkStatus(
OkHttpServices.java:4317)
 at com.marklogic.client.impl.OkHttpServices.postIteratedResourceImpl(
OkHttpServices.java:3831)
 at com.marklogic.client.impl.OkHttpServices.postEvalInvoke(
OkHttpServices.java:3768)
 at com.marklogic.client.impl.ServerEvaluationCallImpl.eval(
ServerEvaluationCallImpl.java:164)
 at com.marklogic.client.impl.ServerEvaluationCallImpl.eval(
ServerEvaluationCallImpl.java:153)
 at com.marklogic.client.impl.ServerEvaluationCallImpl.evalAs(
ServerEvaluationCallImpl.java:144)
 at bulkimport.Tsm.main(Tsm.java:19)

I went through documentation (i.e.https://help.marklogic.com/
knowledgebase/article/View/9/16/resolving-xdmp-expntreecachefull-errors)  where
they had mentioned ways to resolve this error. Following that i had
increased `expanded tree cache size*` to `2048` but still i am facing same
error.

How can i optimize by above code (i.e.`JS.sjs`) to avoid this error ?

Any help is appreciated.
___
General mailing list
General@developer.marklogic.com
Manage your subscription at: 
http://developer.marklogic.com/mailman/listinfo/general


[MarkLogic Dev General] question about transactions

2018-01-24 Thread Erik Zander
Hi All,

I have a question about I think transactions.

I want to insert some rdf and then query the database, and I want to do this in 
a function so I can call the function and depending on if I have the data in 
Marklogic or not get the data as rdf and insert it.

But my problem is that the following code only returns result second time I 
call it.
I’m thankful for pointers here
Regards
Erik
Code below
==

xquery version "1.0-ml" encoding "utf-8";


import module namespace sem = "http://marklogic.com/semantics;
  at "/MarkLogic/semantics.xqy";
declare namespace rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#;;

let $wDataRdf :=
http://www.w3.org/1999/02/22-rdf-syntax-ns#;
  xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#;

  xmlns:wikibase="http://wikiba.se/ontology#;
  xmlns:wd="http://www.wikidata.org/entity/;
  >
http://www.wikidata.org/entity/Q925hhq;>
mup



let $insert :=  xdmp:eval(
'
import module namespace sem = "http://marklogic.com/semantics;
  at "/MarkLogic/semantics.xqy";
declare variable $wDataRdf as node() external;
sem:rdf-insert(sem:rdf-parse($wDataRdf,("rdfxml", 
"graph=http://www.wikidata.org;)))'
,(xs:QName("wDataRdf"), $wDataRdf)
)
return sem:sparql('
PREFIX wd: 
PREFIX rdfs: 
SELECT ?label WHERE {
   wd:Q925hhq  rdfs:label ?label
   FILTER (langMatches( lang(?label), "SV" ) )
}'
)



___
General mailing list
General@developer.marklogic.com
Manage your subscription at: 
http://developer.marklogic.com/mailman/listinfo/general


Re: [MarkLogic Dev General] Exit query without writing to error log?

2018-01-24 Thread David Ennis
HI.

Further to Florent’s comment, assuming your code is OK with the error bubbling 
up to the top, you can catch them all in a single place and act accordingly  
using a custom error handler. Using this in conjunction with throwing your own 
errors (and handling the code in the top-level handler) can be useful.

https://docs.marklogic.com/guide/app-dev/appserver-control#id_89735

Regards,
David

--


From:  on behalf of Florent Georges 

Reply-To: MarkLogic Developer Discussion 
Date: Wednesday, January 24, 2018 at 1:53 PM
To: MarkLogic Developer Discussion 
Subject: Re: [MarkLogic Dev General] Exit query without writing to error log?

Hi Evan,

The error is logged only if it "reaches the top", that is, if it is not caught.

If the error shouldn't behave as such, can't you just catch it before? (and 
yes, potentially return wathever HTTP response you deem appropriate).

Regards,

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


On 24 January 2018 at 03:22, Evan Lenz wrote:
Hello,

My client has XQuery parameter-validation code which calls the error() function 
when invalid parameters are supplied. This event gets written to the error log. 
Is there a way to prevent this?

I recognize the best practice is to return a more appropriate HTTP response 
code (than 500) when handling invalid input. I also recognize this is anathema 
to FP. But my question still stands:

Is there a way to interrupt/exit a query without triggering an Error-level log 
message?

Thanks,

Evan Lenz
President, Lenz Consulting Group, Inc.
http://lenzconsulting.com

___
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] Exit query without writing to error log?

2018-01-24 Thread Florent Georges
Hi Evan,

The error is logged only if it "reaches the top", that is, if it is not
caught.

If the error shouldn't behave as such, can't you just catch it before? (and
yes, potentially return wathever HTTP response you deem appropriate).

Regards,

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


On 24 January 2018 at 03:22, Evan Lenz wrote:

> Hello,
>
> My client has XQuery parameter-validation code which calls the error()
> function when invalid parameters are supplied. This event gets written to
> the error log. Is there a way to prevent this?
>
> I recognize the best practice is to return a more appropriate HTTP
> response code (than 500) when handling invalid input. I also recognize this
> is anathema to FP. But my question still stands:
>
> Is there a way to interrupt/exit a query without triggering an Error-level
> log message?
>
> Thanks,
>
> Evan Lenz
> President, Lenz Consulting Group, Inc.
> http://lenzconsulting.com
>
> ___
> 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