[xsl] how to avoid losing data when the transformation fails

Subject: [xsl] how to avoid losing data when the transformation fails
From: "Wolfhart Totschnig wolfhart.totschnig@xxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Thu, 15 May 2025 17:50:09 -0000
Dear list,

I would like to ask for your advice on the following problem: I have a script that modifies an existing XML file, drawing on external data, changing or complementing the existing data in the file. This means that the source and the output of the transformation are the same file. Now, it has happened that the transformation fails because the external data does not have the form that the script expects it to have. In these cases, the transformation is terminated with an error message and the source file is overwritten with a truncated or even completely empty file. This is a problem because I might lose (and have lost) data in this way, namely when the back-up copy of the source file that I have is not the latest version.

What is the proper way to deal with this problem? Is there a way to instruct Saxon (I am using Saxon 9 HE) not to write an output when the transformation fails? Or should the transformation be organized differently?

Thank you in advance for your help!
Wolfhart

Current Thread