|
next
|
Subject: xquery and try - catch Author: Bruce Cantor Date: 30 Jul 2021 01:55 PM
|
Hi
Any help appreciated here :-)
I need to be able to deliver a log file back to my backend when finishing a file transfer with sftp.
Until now I have been delivering using the sftp option in the pipeline binding file, but I cannot see how I can use this when there is a specific requirement for the log file name. The log file name must follow the name of the input file.
So, I turned to xquery, knowing that I should be able to have access to the input file name.
My problem is I cannot make any try - catch statement work if I use the Datadirect xquery processor. I get errors like this:
DataDirect][XQuery][err:XPST0003]Error at line 2, column 5. Unexpected token "{" beyond end of query.
If I run a script with the Saxon processor I can use try - catch statements, but then I do not have access to the functions that I need to send the file. e.g. sftp:sendFile()
Is it possible to do exception handling in xquery wile using the Datadirect Xquery processor?
script:
xquery version "1.1";
declare namespace xps_sftp = "ddtekjava:com.ivitechnologies.pipeline.ext.net.SFTP";
(: declare variable $ediData as xs:string external;:)
declare variable $config := <root host='ftp.test.com' port='22' path='/Upload' user='*******' password='*******'/>;
declare variable $input as document-node(element(*, xs:untyped)) external;
declare function xps_sftp:sendString($element as element(), $data as xs:string, $targetPath as xs:string) as xs:boolean external;
declare function xps_sftp:sendFile($element as element(), $uriLocalFile as xs:string, $targetPath as xs:string) as xs:boolean external;
let $now := ddtek:format-dateTime(fn:current-dateTime(),'[Y0001][M01][D01][H01][m01][s01]') , $fileName := concat("Dispatch.",$now,'.xml')
return
try {
xps_sftp:sendFile($config,base-uri(/*), $fileName)
}
catch * {
(: write log file here, with error result :)
}
Kind regards
Bruce
|
|
|