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

Subject: Re: [xsl] how to avoid losing data when the transformation fails
From: "Liam R. E. Quin liam@xxxxxxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Thu, 15 May 2025 18:56:42 -0000
On Thu, 2025-05-15 at 17:50 +0000, Wolfhart Totschnig
wolfhart.totschnig@xxxxxxxxxxx wrote:
>
> What is the proper way to deal with this problem?

In most cases the best way is to have Saxon output to a temporary file,
check the status, and then rename the temporary file.

However, within XSLT you can use try/catch

<xsl:initial-templage name="my:wrapper">
  <xsl:try>
    <xsl:apply-templates select="/" />
  </xsl:try>
  <xsl:catch>
    <xsl:copy-of select="/" />
  </xsl:catch>
</xsl:initial-template>

might be one approach, roughly (i didn't try it).

But it might be better to think about how to handle the situation
instead of failing, if possible.

liam

--
Liam Quin,B https://www.delightfulcomputing.com/
Available for XML/Document/Information Architecture/XSLT/
XSL/XQuery/Web/Text Processing/A11Y training, work & consulting.
Barefoot Web-slave, antique illustrations: B http://www.fromoldbooks.org

Current Thread