Regression test for saxon bug: $err:code within a predicate
authorMichael Kay <mike@saxonica.com>
Wed, 13 Jun 2018 12:37:24 +0100
changeset 1856 067c1e8d801d
parent 1855 c36860b47510
child 1857 be6098d1034a
Regression test for saxon bug: $err:code within a predicate
tests/insn/try/_try-test-set.xml
tests/insn/try/try-032.xsl
--- a/tests/insn/try/_try-test-set.xml	Wed Jun 13 12:36:14 2018 +0100
+++ b/tests/insn/try/_try-test-set.xml	Wed Jun 13 12:37:24 2018 +0100
@@ -572,4 +572,20 @@
          <error code="FOAR0001"/>
       </result>
    </test-case>
+   
+   <test-case name="try-032">
+      <description>Saxon bug 3791 - reference to err:code in a predicate</description>
+      <keywords>xsl:try</keywords>
+      <created by="Michael Kay" on="2018-05-25"/>
+      <dependencies>
+         <spec value="XSLT30+"/>
+      </dependencies>
+      <test>
+         <stylesheet file="try-032.xsl"/>
+         <initial-template name="main"/>
+      </test>
+      <result>
+         <assert>/out='test: Bang!'</assert>
+      </result>
+   </test-case>
 </test-set>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/insn/try/try-032.xsl	Wed Jun 13 12:37:24 2018 +0100
@@ -0,0 +1,17 @@
+<xsl:stylesheet exclude-result-prefixes="#all" version="3.0" 
+  xmlns:err="http://www.w3.org/2005/xqt-errors" xmlns:xs="http://www.w3.org/2001/XMLSchema" 
+  xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+
+  <!-- Saxon bug 3791 - reference to $err:code in a predicate -->
+
+  <xsl:template name="main">
+    <out>
+      <xsl:variable as="xs:QName" name="my-err" select="xs:QName('my-err-local')" />
+      <xsl:try select="error($my-err)">
+        <xsl:catch>
+          <xsl:value-of select="'test:', 'Bang!'[$err:code eq $my-err]" />
+        </xsl:catch>
+      </xsl:try>
+    </out>  
+  </xsl:template>
+</xsl:stylesheet>
\ No newline at end of file