Adding more circularity error tests with xsl:evaluate and xsl:try/catch
authorabraaksm
Mon, 30 Mar 2015 20:09:46 +0200
changeset 897 bff5fe982eb5
parent 896 b99b90a57a1c
child 898 d24fc7befec7
Adding more circularity error tests with xsl:evaluate and xsl:try/catch
tests/misc/error/_error-test-set.xml
tests/misc/error/error-0640i.xsl
tests/misc/error/error-0640j.xsl
tests/misc/error/error-0640k.xsl
tests/misc/error/error-0640l.xsl
tests/misc/error/error-0640m.xsl
tests/misc/error/error-0640n.xsl
tests/misc/error/error-0640o.xsl
tests/misc/error/error-0640p.xsl
--- a/tests/misc/error/_error-test-set.xml	Mon Mar 30 19:32:24 2015 +0200
+++ b/tests/misc/error/_error-test-set.xml	Mon Mar 30 20:09:46 2015 +0200
@@ -4510,8 +4510,8 @@
 
    <test-case name="error-0640h">
       <description>Generate error XTDE0640.
-Was error-code-262.
-In general, a circularity in a stylesheet is a non-recoverable dynamic error.</description>
+         Was error-code-262.
+         In general, a circularity in a stylesheet is a non-recoverable dynamic error.</description>
       <created by="Michael Kay" on="2012-11-07"/>
       <environment ref="error001"/>
       <dependencies>
@@ -4526,6 +4526,151 @@
       </result>
    </test-case>
 
+   <test-case name="error-0640i">
+      <description>
+         Generate error XTDE0640 (circularity error) with xsl:evaluate in xsl:param
+      </description>
+      <created by="Abel Braaksma" on="2015-03-30"/>
+      <dependencies>
+         <spec value="XSLT30+"/>
+      </dependencies>
+      <test>
+         <stylesheet file="error-0640i.xsl"/>
+      </test>
+      <result>
+         <error code="XTDE0640"/>
+      </result>
+   </test-case>
+
+   <test-case name="error-0640j">
+      <description>
+         Generate error XTDE0640 (circularity error) with xsl:evaluate in xsl:variable
+      </description>
+      <created by="Abel Braaksma" on="2015-03-30"/>
+      <dependencies>
+         <spec value="XSLT30+"/>
+      </dependencies>
+      <test>
+         <stylesheet file="error-0640j.xsl"/>
+      </test>
+      <result>
+         <error code="XTDE0640"/>
+      </result>
+   </test-case>
+
+   <test-case name="error-0640k">
+      <description>
+         Generate error XTDE0640 (circularity error) with anonymous function in seqtor
+      </description>
+      <created by="Abel Braaksma" on="2015-03-30"/>
+      <dependencies>
+         <spec value="XSLT30+"/>
+      </dependencies>
+      <test>
+         <stylesheet file="error-0640k.xsl"/>
+      </test>
+      <result>
+         <error code="XTDE0640"/>
+      </result>
+   </test-case>
+
+   <test-case name="error-0640l">
+      <description>
+         Generate error XTDE0640 (circularity error) with anonymous function in select expr
+      </description>
+      <created by="Abel Braaksma" on="2015-03-30"/>
+      <dependencies>
+         <spec value="XSLT30+"/>
+      </dependencies>
+      <test>
+         <stylesheet file="error-0640l.xsl"/>
+      </test>
+      <result>
+         <error code="XTDE0640"/>
+      </result>
+   </test-case>
+
+   <test-case name="error-0640m">
+      <description>
+         Generate error XTDE0640 (circularity error) and trying to catch it with xsl:try/catch (not allowed, see Bug 28368)
+      </description>
+      <created by="Abel Braaksma" on="2015-03-30"/>
+      <dependencies>
+         <spec value="XSLT30+"/>
+      </dependencies>
+      <test>
+         <stylesheet file="error-0640m.xsl"/>
+      </test>
+      <result>
+         <error code="XTDE0640"/>
+      </result>
+   </test-case>
+
+   <test-case name="error-0640n">
+      <description>
+         Generate error XTDE0640 (circularity error) raised through xsl:evaluate and trying to catch it with xsl:try/catch in a function (not allowed, see Bug 28368)
+      </description>
+      <created by="Abel Braaksma" on="2015-03-30"/>
+      <dependencies>
+         <spec value="XSLT30+"/>
+      </dependencies>
+      <test>
+         <stylesheet file="error-0640n.xsl"/>
+      </test>
+      <result>
+         <error code="XTDE0640"/>
+      </result>
+   </test-case>
+
+   <test-case name="error-0640o-1">
+      <description>
+         Generate error XTDE0640 (circularity error) NOT raised for static params (they are not forward in scope, raise XPST0008)
+      </description>
+      <created by="Abel Braaksma" on="2015-03-30"/>
+      <dependencies>
+         <spec value="XSLT30+"/>
+      </dependencies>
+      <test>
+         <stylesheet file="error-0640o.xsl"/>
+      </test>
+      <result>
+         <error code="XPST0008"/>
+      </result>
+   </test-case>
+
+   <test-case name="error-0640o-2">
+      <description>
+         Generate error XTDE0640 (circularity error) NOT raised for static params if you set the value externally
+      </description>
+      <created by="Abel Braaksma" on="2015-03-30"/>
+      <dependencies>
+         <spec value="XSLT30+"/>
+      </dependencies>
+      <test>
+         <stylesheet file="error-0640o.xsl"/>
+         <param name="circular" select="true()" />
+      </test>
+      <result>
+         <assert-xml><![CDATA[<out/>]]></assert-xml>
+      </result>
+   </test-case>
+
+   <test-case name="error-0640p">
+      <description>
+         Generate error XTDE0640 (circularity error) NOT raised for static variables (they are not forward in scope, raise XPST0008)
+      </description>
+      <created by="Abel Braaksma" on="2015-03-30"/>
+      <dependencies>
+         <spec value="XSLT30+"/>
+      </dependencies>
+      <test>
+         <stylesheet file="error-0640p.xsl"/>
+      </test>
+      <result>
+         <error code="XPST0008"/>
+      </result>
+   </test-case>
+
    <test-case name="error-0650a">
       <description>Error: xsl:call-template.
 Was error-code-049.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/misc/error/error-0640i.xsl	Mon Mar 30 20:09:46 2015 +0200
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--In general, a circularity in a stylesheet is a non-recoverable dynamic error.-->
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="3.0">
+
+<!-- Test circular reference through xsl:evaluate in a param XPDE0640 -->
+
+  <xsl:param name="p">
+    <xsl:evaluate xpath="'$y'" />
+  </xsl:param>
+  
+  <xsl:param name="y">
+    <xsl:evaluate xpath="'$p'" />
+  </xsl:param>
+
+  <xsl:template name="xsl:initial-template">
+      <out wrong="{$p}"/>
+  </xsl:template>
+   
+</xsl:stylesheet>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/misc/error/error-0640j.xsl	Mon Mar 30 20:09:46 2015 +0200
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--In general, a circularity in a stylesheet is a non-recoverable dynamic error.-->
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="3.0">
+
+<!-- Test circular reference through xsl:evaluate in a variable XPDE0640 -->
+
+  <xsl:variable name="p">
+    <xsl:evaluate xpath="'$y'" />
+  </xsl:variable>
+  
+  <xsl:variable name="y">
+    <xsl:evaluate xpath="'$p'" />
+  </xsl:variable>
+
+  <xsl:template name="xsl:initial-template">
+      <out wrong="{$p}"/>
+  </xsl:template>
+   
+</xsl:stylesheet>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/misc/error/error-0640k.xsl	Mon Mar 30 20:09:46 2015 +0200
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--In general, a circularity in a stylesheet is a non-recoverable dynamic error.-->
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="3.0">
+
+<!-- Test circular reference through anonymous function XPDE0640-->
+ 
+  <xsl:variable name="circular">
+    <xsl:sequence select="$other()" />
+  </xsl:variable>
+  
+  <xsl:variable name="other" as="function(*)">
+    <xsl:sequence select="function(){$circular}" />
+  </xsl:variable>
+
+  <xsl:template name="xsl:initial-template">
+      <out wrong="{$circular}"/>
+  </xsl:template>
+   
+</xsl:stylesheet>
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/misc/error/error-0640l.xsl	Mon Mar 30 20:09:46 2015 +0200
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--In general, a circularity in a stylesheet is a non-recoverable dynamic error.-->
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="3.0">
+
+<!-- Test circular reference through anonymous function XPDE0640-->
+ 
+  <xsl:variable name="circular" select="$other()" />
+  
+  <xsl:variable name="other" as="function(*)" select="function(){$circular}" />
+
+  <xsl:template name="xsl:initial-template">
+      <out wrong="{$circular}"/>
+  </xsl:template>
+   
+</xsl:stylesheet>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/misc/error/error-0640m.xsl	Mon Mar 30 20:09:46 2015 +0200
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--In general, a circularity in a stylesheet is a non-recoverable dynamic error.-->
+<xsl:stylesheet 
+    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+    xmlns:err="http://www.w3.org/2005/xqt-errors"
+    version="3.0">
+
+<!-- Test circular reference, trying to catch the error XPDE0640
+    See bug 28368 about capturing circularity errors (will likely become disallowed) -->
+ 
+  <xsl:variable name="circular">
+      <xsl:try>
+          <xsl:sequence select="$other" />
+          <xsl:catch errors="err:XTDE0640">
+              A) You cannot catch this error!
+          </xsl:catch>
+      </xsl:try>
+  </xsl:variable>
+  
+  <xsl:variable name="other">
+      <xsl:try>
+          <xsl:sequence select="$circular" />
+          <xsl:catch errors="err:XTDE0640">
+              B) You cannot catch this error!
+          </xsl:catch>
+      </xsl:try>
+  </xsl:variable>
+
+  <xsl:template name="xsl:initial-template">
+      <out wrong="{$circular}"/>
+  </xsl:template>
+   
+</xsl:stylesheet>
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/misc/error/error-0640n.xsl	Mon Mar 30 20:09:46 2015 +0200
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--In general, a circularity in a stylesheet is a non-recoverable dynamic error.-->
+<xsl:stylesheet 
+    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+    xmlns:err="http://www.w3.org/2005/xqt-errors"
+    xmlns:my="http://example.com/myfunctions"
+    version="3.0">
+
+<!-- Test circular reference, trying to catch the error XPDE0640 when dynamically raised with xsl:evaluate
+    See bug 28368 about capturing circularity errors (will likely become disallowed) -->
+ 
+    <xsl:variable name="circular">
+        <xsl:evaluate xpath="'$other'" />
+    </xsl:variable>
+    
+    <xsl:variable name="other">
+        <xsl:evaluate xpath="'$circular'" />
+    </xsl:variable>
+  
+    <xsl:template name="xsl:initial-template">
+        <out wrong="{my:catch-circular()}"/>
+    </xsl:template>
+    
+    <xsl:function name="my:catch-circular">
+        <xsl:try>
+            <xsl:value-of select="$other" />
+            <xsl:catch errors="err:XTDE0640">
+                B) You cannot catch this error!
+            </xsl:catch>
+        </xsl:try>
+    </xsl:function>
+   
+</xsl:stylesheet>
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/misc/error/error-0640o.xsl	Mon Mar 30 20:09:46 2015 +0200
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--In general, a circularity in a stylesheet is a non-recoverable dynamic error.-->
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="3.0">
+
+<!-- Test circular reference, trying to catch the error XPDE0640 when dynamically raised with xsl:evaluate
+    See bug 28368 about capturing circularity errors (will likely become disallowed) -->
+ 
+    <xsl:param name="circular" static="yes" select="$other" />
+    
+    <xsl:param name="other" static="yes" select="$circular" />
+  
+    <xsl:template name="xsl:initial-template" use-when="$other">
+        <out />
+    </xsl:template>
+   
+</xsl:stylesheet>
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/misc/error/error-0640p.xsl	Mon Mar 30 20:09:46 2015 +0200
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--In general, a circularity in a stylesheet is a non-recoverable dynamic error.-->
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="3.0">
+
+<!-- Test circular reference, trying to catch the error XPDE0640 when dynamically raised with xsl:evaluate
+    See bug 28368 about capturing circularity errors (will likely become disallowed) -->
+ 
+    <xsl:variable name="circular" static="yes" select="$other" />
+    
+    <xsl:variable name="other" static="yes" select="$circular" />
+  
+    <xsl:template name="xsl:initial-template" use-when="$circular">
+        <out />
+    </xsl:template>
+   
+</xsl:stylesheet>
+