1
votes

Having file like this :

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    exclude-result-prefixes="xs">

    <xsl:import href="file0.xsl"/>
    <xsl:import href="file1.xsl"/>
    <xsl:import href="file2.xsl"/>

    <xsl:output indent="yes"/>

    <xsl:template match="/">
        <root>
            <xsl:result-document href="../xml/file0.xml" method="xml">
                <xsl:call-template name="file0"/>
            </xsl:result-document>

            <xsl:result-document href="../xml/file1.xml" method="xml">
                <xsl:call-template name="file1"/>
            </xsl:result-document>

            <xsl:result-document href="../xml/file2.xml" method="xml">
                <xsl:call-template name="file2"/>
            </xsl:result-document>
        </root> 
    </xsl:template>

</xsl:stylesheet>

Q: I'm wandering if there is a way to continue transformation if one of the result-document elements fail to execute.

e.g. file1.xsl throws an error in template file1, will the file2 template be executed???

1
What kind of error do you have in mind? try/catch is a feature of the XSLT 3.0, not 2.0. - Martin Honnen
I'm aware of XSLT 3.0 functionalities. I'm using Saxon 9.6 HE right now and there is no possibility for me to migrate to 3.0. I just want to assure that even if one of the files fail the rest still will be written. Perhaps is there any Java way to handle the error without stopping the entire solution. The example above is just a mock, I have about 30 files I write to, all works fine right now, but what if something goes wrong.\ - Piotr Dajlido
I have added the tag for Saxon, maybe Michael Kay has an idea that can help you further. - Martin Honnen
Thank you very much for your time and involvement. I just want to let you know that even if it is not possible in Saxon HE, I can accept that as an answer. - Piotr Dajlido
There's no try/catch in Saxon-HE. You'll need to fork out £50 for a PE license. - Michael Kay

1 Answers

3
votes

There's no try/catch capability in XSLT 2.0 or in Saxon-HE. The facility is present in XSLT 3.0 (and as a Saxon extension to XSLT 2.0), but in both cases, that's not available in the free version of the product.