Hi Greet,
I tried to implement pre-commit solution. In my action module I am trying check
if input xml adheres to xml my predefined xml schema
Then only it should commit the file if not it should fail.
In order to do so, I am written pre-trigger action module as follows -
xquery version '1.0-ml';
(: evaluate this against the database specified
in the trigger definition (test in this example)
:)
xdmp:document-insert("/modules/log.xqy",
text{ "
xquery version '1.0-ml';
import module namespace trgr='http://marklogic.com/xdmp/triggers'
at '/MarkLogic/triggers.xqy';
declare variable $trgr:uri as xs:string external;
try { (xdmp:log(fn:concat('*****Document ', $trgr:uri, ' was created.*****')),
let $root := fn:doc($trgr:uri)/*
return $root)
}
catch ($e) { 'Validation failed: ', $e/error:format-string/text() }
"}, xdmp:permission('app-user', 'execute'))
My question is how do I force commit to fail. I tried returning fn:false() in
above try block but it doesn't work.
What should I return in try block to prevent ingestion. May be a silly one but
I am not getting around it.
Thanks,
Abhishek Jain
From: [email protected]
[mailto:[email protected]] On Behalf Of Jain, Abhishek
Sent: Wednesday, September 21, 2016 8:26 PM
To: MarkLogic Developer Discussion
Subject: Re: [MarkLogic Dev General] Validate XML documents while ingesting and
maintain logs of failed documents #CGO#
WARNING: Kindly be aware the Sender Address on this mail may be forged. It
appears to be from capgemini.com but the message has been received from a
server outside Capgemini Group perimeter. User discretion is necessary before
performing actions mentioned in this mail.
Thanks for the quick input, just had a look at pre-commit trigger, looks like
a solution, will give it a try.
MLCP/pre-commit will do, Writing off CPF solution for post-commit over-head
reason, As I need to upload 1 TB Data.
Thank a lot.
[Email_CBE.gif]Abhishek Jain
Associate Consultant
Capgemini India | Hyderabad
From:
[email protected]<mailto:[email protected]>
[mailto:[email protected]] On Behalf Of Geert Josten
Sent: Wednesday, September 21, 2016 6:53 PM
To: MarkLogic Developer Discussion
Subject: Re: [MarkLogic Dev General] Validate XML documents while ingesting and
maintain logs of failed documents #CGO#
Hi Abhishek,
Sounds right overall. An MLCP transform gives some flexibility when you want to
validate or not. If you want to enforce it more strictly, you can use a
pre-commit trigger, and deny commit if it doesn't validate by (re)throwing an
error (or not catching the validate error).
I would recommend using a pre-commit trigger over CPF if it is only for
validation. CPF comes with extra overhead, and actions run in post-commit too.
You would not be able to prevent inserts, but only able to flag docs as being
invalid..
Cheers,
Geert
From:
<[email protected]<mailto:[email protected]>>
on behalf of "Jain, Abhishek"
<[email protected]<mailto:[email protected]>>
Reply-To: MarkLogic Developer Discussion
<[email protected]<mailto:[email protected]>>
Date: Wednesday, September 21, 2016 at 3:03 PM
To: "[email protected]<mailto:[email protected]>"
<[email protected]<mailto:[email protected]>>
Subject: [MarkLogic Dev General] Validate XML documents while ingesting and
maintain logs of failed documents #CGO#
Hi Folks,
I'm working on a use-case where I need to ingest bulk documents into Marklogic,
only those documents which adhere to predefined ( have written my own)
XML schema should be loaded into DB. If fails then details should be written in
a log file. My approach to achieve this so far is :
1. Create an XSD.
2. Write a MLCP transformation module or content processing framework
module
3. Validate content of each document inside the module and using try ...
catch block
4. If content is valid - insert , if not write to failed list (logs)
Am I going right ?
Can anyone share with me the best approach ?
Is there any other way of doing this than mlcp and CPF ?
Thanks and Regards,
[Email_CBE.gif]Abhishek Jain
Associate Consultant
People matter, results count.
This message contains information that may be privileged or confidential and is
the property of the Capgemini Group. It is intended only for the person to whom
it is addressed. If you are not the intended recipient, you are not authorized
to read, print, retain, copy, disseminate, distribute, or use this message or
any part thereof. If you receive this message in error, please notify the
sender immediately and delete all copies of this message.
_______________________________________________
General mailing list
[email protected]
Manage your subscription at:
http://developer.marklogic.com/mailman/listinfo/general