Further xsl:try/catch tests with variables; and correct test that uses element-available
authorMichael Kay <mike@saxonica.com>
Tue, 30 Jun 2015 00:07:58 +0100
changeset 992 4a85730988dc
parent 991 92f2ab138d68
child 993 77c252949c59
Further xsl:try/catch tests with variables; and correct test that uses element-available
tests/insn/try/_try-test-set.xml
tests/insn/try/try-029.xsl
tests/insn/try/try-030.xsl
tests/insn/try/try-031.xsl
--- a/tests/insn/try/_try-test-set.xml	Mon Jun 29 15:58:26 2015 +0100
+++ b/tests/insn/try/_try-test-set.xml	Tue Jun 30 00:07:58 2015 +0100
@@ -200,9 +200,10 @@
    </test-case>
 
    <test-case name="try-012">
-      <description>element-available in Saxon-SA</description>
-      <keywords>fn:element-available xsl:try xsl:catch _WRONG:test-output-incorrect</keywords>
+      <description>element-available on xsl:try/catch</description>
+      <keywords>fn:element-available xsl:try xsl:catch</keywords>
       <created by="Michael Kay" on="2012-11-07"/>
+      <created by="Michael Kay" on="2015-06-29" change="spec of element-available() has changed in 3.0"/>
       <dependencies>
          <spec value="XSLT30+"/>
       </dependencies>
@@ -211,12 +212,12 @@
          <initial-template name="main"/>
       </test>
       <result>
-         <assert-xml><![CDATA[<out try="true" catch="false"/>]]></assert-xml>
+         <assert-xml><![CDATA[<out try="true" catch="true"/>]]></assert-xml>
       </result>
    </test-case>
 
    <test-case name="try-013">
-      <description>element-available in Saxon-B</description>
+      <description>element-available on xsl:try/catch in XSLT 2.0</description>
       <keywords>fn:element-available xsl:try xsl:catch 2.0-only-behavior</keywords>
       <created by="Michael Kay" on="2012-11-07"/>
       <dependencies>
@@ -534,4 +535,37 @@
          <error code="FOAR0001"/>
       </result>
    </test-case>
+   
+   <test-case name="try-030">
+      <description>error in evaluating local variable is not caught</description>
+      <keywords>xsl:try</keywords>
+      <created by="Michael Kay" on="2015-06-29"/>
+      <dependencies>
+         <spec value="XSLT30+"/>
+      </dependencies>
+      <test>
+         <stylesheet file="try-030.xsl"/>
+         <initial-template name="main"/>
+      </test>
+      <result>
+         <error code="FOAR0001"/>
+      </result>
+   </test-case>
+   
+   <test-case name="try-031">
+      <description>error in evaluating local variable is not caught</description>
+      <keywords>xsl:try</keywords>
+      <created by="Michael Kay" on="2015-06-29"/>
+      <environment ref="try020"/>
+      <dependencies>
+         <spec value="XSLT30+"/>
+      </dependencies>
+      <test>
+         <stylesheet file="try-031.xsl"/>
+         <initial-template name="main"/>
+      </test>
+      <result>
+         <error code="FOAR0001"/>
+      </result>
+   </test-case>
 </test-set>
\ No newline at end of file
--- a/tests/insn/try/try-029.xsl	Mon Jun 29 15:58:26 2015 +0100
+++ b/tests/insn/try/try-029.xsl	Tue Jun 30 00:07:58 2015 +0100
@@ -5,10 +5,9 @@
 
     <xsl:param name="p" select="0"/>
     
-    
     <xsl:template match="/" name="main">
         <output>
-            <xsl:variable name="q" select="22 div $p"/>
+                <xsl:variable name="q" select="22 div $p"/>
                 <xsl:try>
                     <out><xsl:value-of select="$q"/></out>
                     <xsl:catch>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/insn/try/try-030.xsl	Tue Jun 30 00:07:58 2015 +0100
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xsl:stylesheet version="3.0" 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"
+    exclude-result-prefixes="xs">
+
+    <xsl:param name="p" select="10"/>
+    
+    <xsl:template match="/" name="main">
+        <output>
+           <xsl:for-each select="1 to $p">
+                <xsl:variable name="q" select="22 div (. - 1)"/>
+                <xsl:try>
+                    <out><xsl:value-of select="$q"/></out>
+                    <xsl:catch>
+                        <caught/>
+                    </xsl:catch>
+                </xsl:try>
+           </xsl:for-each>
+        </output>
+    </xsl:template>
+</xsl:stylesheet>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/insn/try/try-031.xsl	Tue Jun 30 00:07:58 2015 +0100
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xsl:stylesheet version="3.0" 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"
+    exclude-result-prefixes="xs">
+
+    <xsl:param name="p" select="10"/>
+    <xsl:param name="root" select="/"/>
+    
+    <xsl:template match="/" name="main">
+        <output>
+           <xsl:for-each select="1 to $p">
+                <xsl:variable name="q" select="$root//*[position() = 22 div (current() - 1)]"/>
+                <xsl:try>
+                    <out><xsl:value-of select="$q"/></out>
+                    <xsl:catch>
+                        <caught/>
+                    </xsl:catch>
+                </xsl:try>
+           </xsl:for-each>
+        </output>
+    </xsl:template>
+</xsl:stylesheet>