Project

Profile

Help

Bug #4227 ยป test.xsl

Jan Pertermann, 2019-05-24 13:02

 
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:err="http://www.w3.org/2005/xqt-errors"
version="3.0">
<xsl:param name="test" as="xs:integer" select="1"/>
<xsl:template name="main">
<!--
Prerequisites
=============
* Directory with the name 'example'
in same path as the current xsl
* Windows
* Saxon 9.8.0.12 (Java)
* or Saxon 9.8.0.15 (.Net)
Note: Change $test to 1, 2, ...
-->
<xsl:message select="'Running ' || $test"/>
<xsl:choose>
<!--
(1) Leads to an undefined error
(java.io.FileNotFoundException)
(Somehow) as expected.
-->
<xsl:when test="$test eq 1">
<xsl:result-document href="{resolve-uri('example')}">
<root></root>
</xsl:result-document>
</xsl:when>
<!--
(2) Nothing here as we catch the error
As expected.
-->
<xsl:when test="$test eq 2">
<xsl:try>
<xsl:result-document href="{resolve-uri('example')}">
<root></root>
</xsl:result-document>
<xsl:catch>
</xsl:catch>
</xsl:try>
</xsl:when>
<!--
(3) Leads to java.lang.NullPointerException
Expected behaviour: Second catch must match
and no error is thrown at the end.
-->
<xsl:when test="$test eq 3">
<xsl:try>
<xsl:result-document href="{resolve-uri('example')}">
<root></root>
</xsl:result-document>
<xsl:catch errors="err:*">
</xsl:catch>
<xsl:catch>
</xsl:catch>
</xsl:try>
</xsl:when>
<!--
(4) Let's see what happens when we provoke
a specified dynamic error ...
As expected.
-->
<xsl:when test="$test eq 4">
<xsl:try>
<xsl:sequence select="parse-xml('&lt;not-well&gt;')"/>
<xsl:catch errors="err:*">
</xsl:catch>
<xsl:catch>
</xsl:catch>
</xsl:try>
</xsl:when>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
    (1-1/1)