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

Subject: Re: [xsl] how to avoid losing data when the transformation fails
From: "Wendell Piez wapiez@xxxxxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Thu, 15 May 2025 18:50:46 -0000
Hello Wolfhart,

This gets XSLT into the area of workflow and resource (dependency)
management, and it is a functional language, designed to work the same
across different implementations (and architectures, including caching
architectures). So you run up against all kinds of problems when you try to
do this internally. (And some of them may depend on your platform,
operating environment, etc.)

In my experience it's much better to write results to a designated location
(not the same as the nominal source) and then mirror them (copying over the
source, if you want) in a separate operation. You could do this in a shell
script, in the language of your choice (e.g. Java), or in (say) XProc.

In one respect at least, the name "transformation" is somewhat unfortunate:
it leads one to think that XSLT is about 'changing' something, when it's
really about creating a new thing based on the old thing.

Regards, Wendell



On Thu, May 15, 2025 at 2:04b/PM Wolfhart Totschnig
wolfhart.totschnig@xxxxxxxxxxx <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
wrote:

>
> > 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?
>
> Sorry for not having been clear. The situation is that, when I call
> Saxon, the source and the output are the same file:
>
> java -cp "/home/wolfhart/Programs/Saxon/saxon9he.jar"
> net.sf.saxon.Transform -s:biblio.xml -xsl:new_biblio.xsl -o:biblio.xml
>
> So, when new_biblio.xsl fails because of an unforeseen error (often due
> to external data not having the expected form), I get a truncated or
> empty biblio.xml.
>
>
>

--
...Wendell Piez... ...wendell -at- nist -dot- gov...
...wendellpiez.com... ...pellucidliterature.org... ...pausepress.org...
...github.com/wendellpiez... ...gitlab.coko.foundation/wendell...

Current Thread