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

Subject: Re: [xsl] how to avoid losing data when the transformation fails
From: "Martin Honnen martin.honnen@xxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Thu, 15 May 2025 17:54:11 -0000
On 15/05/2025 19:50, Wolfhart Totschnig wolfhart.totschnig@xxxxxxxxxxx
wrote:
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?



Is that an XSLT problem in that the XSLT processor really reads and writes the same file in a single transformation?

Or should your "script" somehow note that the XSLT failed to produce a
normal result and in that case not overwrite the input?

Current Thread