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?
Subject:xquery and try - catch Author:Ivan Pedruzzi Date:30 Jul 2021 08:52 PM Originally Posted: 30 Jul 2021 08:47 PM
DataDirect XQuery supports the following specifications:
XQuery 1.0 An XML Query Language
XQuery 1.0 and XPath 2.0 Data Model (XDM)
XQuery 1.0 and XPath 2.0 Functions and Operators
XQuery 1.0 and XPath 2.0 Formal Semantics
XQuery 1.1 W3C Working Draft 3
Currently XML Pipeline Server does not allow to use any either XQuery Processor.
One possibility is adding new built-in (S)FTP functions that wrap runtime exceptions and return an XML fragment instead of a Boolean.
Subject:xquery and try - catch Author:Bruce Cantor Date:02 Aug 2021 07:53 AM
That sounds like a good idea.
FTP connections are not stable, the server may be busy or unavailable, we even experience that IP's are sometimes blocked or accounts are changed without warned, I do not think these kind of problems should result in runtime errors. My opinion is that runtime errors are errors that no one really could predict, and this is a type of error that will happen once in a while.
I like the idea of an XML result with status of the different steps.
The status attribute also makes it possible for me to parse the result of the upload as Success or Failed.