hi i am doing the ingestion and validation but i want to record the start time and end time of the ingestion and validation. below are my code what i am doing wrong please suggest.
let $pipelineXml :=
<pipeline id='a111' name='ACH-export' xmlns='http://cms.bloomsbury.com/pipeline'>
<transform href='/transforms/docbook2xml.xsl'/>
<validate href='/validation/taxonomy.sch' failOnError='true'/>
</pipeline>
let $reportChunk := <report>
<info>
<id>{$pipelineXml//@id}</id>
<name>{$pipelineXml//@name}</name>
<submitted-on>{fn:current-dateTime()}</submitted-on>
<user>{user:current()}</user>
</info>
<ingestion-report>
<steps/>
</ingestion-report>
</report>
let $startTime := fn:current-dateTime()
let $validate := validate:rng-report($pipelineXml, bin:decode-string(db:retrieve($config:Database, fn:concat($config:ValidationDir,$config:PipelineRelaxNG)),'UTF-8'), fn:true())
return
if($validate/status='valid')
then
(
admin:write-log("[" || "][Pipeline is valid as per Relax NG : " || $pipelineXml//@id || "]")
,
let $appendReport := let $updateReport := <step>
<type>RELAX NG Validation</type>
<started-on>{$startTime,prof:sleep(20000)}</started-on>
<completed-on>{fn:current-dateTime()}</completed-on>
<status>Pass</status>
<error></error>
</step>
return
copy $target := $reportChunk
modify insert node $updateReport as last into $target/ingestion-report/steps
return $target
return $appendReport
)
else "error"
Hi Dharmendra Kumar Singh,
the
current-Time()
function is a so called deterministic function, which translates to:That being said: your
startTime
andendTime
are identical.Still, you have several possibilities, depending on your actual needs:
prof:current-ns
(which is a non-deterministic function) to get a timestamp and use that value to calculate your times:http://docs.basex.org/wiki/Profiling_Module#prof:current-ns
Or you could use the built-in timing function
prof:time
which logs the time needed for execution:http://docs.basex.org/wiki/Profiling_Module#prof:time
You could write something like:
Yielding the following results:
Sidenote: whats the
bin:decode-string(db:retrieve…)
part for? You might want to replace that with adb:open('…path-to-file…')
and store your Relax-NG schema as an XML file instead of a binary?