Add tests for declared-modes attribute
authorMichael Kay <mike@saxonica.com>
Wed, 19 Aug 2015 18:37:10 +0100
changeset 1046 4ab55840e2a9
parent 1045 6d51333a8d63
child 1047 5cd6fb2edbd1
Add tests for declared-modes attribute
catalog.xml
tests/attr/declared-modes/_declared-modes-test-set.xml
tests/attr/declared-modes/declared-modes-001.xsl
tests/attr/declared-modes/declared-modes-002.xsl
tests/attr/declared-modes/declared-modes-003.xsl
tests/attr/declared-modes/declared-modes-004.xsl
tests/attr/declared-modes/declared-modes-005.xsl
tests/attr/declared-modes/declared-modes-006.xsl
tests/attr/declared-modes/declared-modes-007.xsl
tests/attr/declared-modes/declared-modes-008.xsl
tests/attr/declared-modes/declared-modes-009.xsl
tests/attr/declared-modes/declared-modes-010.xsl
tests/attr/declared-modes/declared-modes-011.xsl
tests/attr/declared-modes/declared-modes-012.xsl
tests/attr/declared-modes/declared-modes-013.xsl
tests/attr/declared-modes/declared-modes-014.xsl
--- a/catalog.xml	Tue Aug 18 18:22:28 2015 +0100
+++ b/catalog.xml	Wed Aug 19 18:37:10 2015 +0100
@@ -6,6 +6,7 @@
 
       <test-set name="as" file="tests/attr/as/_as-test-set.xml"/>
       <test-set name="avt" file="tests/attr/avt/_avt-test-set.xml"/>
+      <test-set name="declared-modes" file="tests/attr/declared-modes/_declared-modes-test-set.xml"/>
       <test-set name="expand-text" file="tests/attr/expand-text/_expand-text-test-set.xml"/>
       <test-set name="match" file="tests/attr/match/_match-test-set.xml"/>
       <test-set name="mode" file="tests/attr/mode/_mode-test-set.xml"/>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/attr/declared-modes/_declared-modes-test-set.xml	Wed Aug 19 18:37:10 2015 +0100
@@ -0,0 +1,179 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<test-set xmlns="http://www.w3.org/2012/10/xslt-test-catalog" xmlns:xs="http://www.w3.org/2001/XMLSchema" name="declared-modes">
+   <description>Tests the effect of the declared-modes attribute on xsl:package (or its absence)</description>
+
+   <dependencies>
+     <spec value="XSLT30+"/>
+   </dependencies>
+   
+   <test-case name="declared-modes-001">
+      <description>By default within a package mode used on xsl:template must be declared</description>
+      <created by="Michael Kay" on="2015-08-19"/>     
+      <test>
+         <stylesheet file="declared-modes-001.xsl"/>
+         <initial-template name="main"/>
+      </test>
+      <result>
+         <error code="XTSE3085"/>
+      </result>
+   </test-case>
+   
+   <test-case name="declared-modes-002">
+      <description>By default within a package mode used on xsl:apply-templates must be declared</description>
+      <created by="Michael Kay" on="2015-08-19"/>     
+      <test>
+         <stylesheet file="declared-modes-002.xsl"/>
+         <initial-template name="main"/>
+      </test>
+      <result>
+         <error code="XTSE3085"/>
+      </result>
+   </test-case>
+   
+   <test-case name="declared-modes-003">
+      <description>By default within a package, unnamed mode used implicitly on xsl:template must be declared</description>
+      <created by="Michael Kay" on="2015-08-19"/>     
+      <test>
+         <stylesheet file="declared-modes-003.xsl"/>
+         <initial-template name="main"/>
+      </test>
+      <result>
+         <error code="XTSE3085"/>
+      </result>
+   </test-case>
+   
+   <test-case name="declared-modes-004">
+      <description>By default within a package, unnamed mode used implicitly on xsl:apply-templates must be declared</description>
+      <created by="Michael Kay" on="2015-08-19"/>     
+      <test>
+         <stylesheet file="declared-modes-004.xsl"/>
+         <initial-template name="main"/>
+      </test>
+      <result>
+         <error code="XTSE3085"/>
+      </result>
+   </test-case>
+   
+   <test-case name="declared-modes-005">
+      <description>With declared-modes='yes' within a package mode used on xsl:template must be declared</description>
+      <created by="Michael Kay" on="2015-08-19"/>     
+      <test>
+         <stylesheet file="declared-modes-005.xsl"/>
+         <initial-template name="main"/>
+      </test>
+      <result>
+         <error code="XTSE3085"/>
+      </result>
+   </test-case>
+   
+   <test-case name="declared-modes-006">
+      <description>With declared-modes='yes' within a package mode used on xsl:apply-templates must be declared</description>
+      <created by="Michael Kay" on="2015-08-19"/>     
+      <test>
+         <stylesheet file="declared-modes-006.xsl"/>
+         <initial-template name="main"/>
+      </test>
+      <result>
+         <error code="XTSE3085"/>
+      </result>
+   </test-case>
+   
+   <test-case name="declared-modes-007">
+      <description>With declared-modes='yes' within a package, unnamed mode used implicitly on xsl:template must be declared</description>
+      <created by="Michael Kay" on="2015-08-19"/>     
+      <test>
+         <stylesheet file="declared-modes-007.xsl"/>
+         <initial-template name="main"/>
+      </test>
+      <result>
+         <error code="XTSE3085"/>
+      </result>
+   </test-case>
+   
+   <test-case name="declared-modes-008">
+      <description>With declared-modes='yes' within a package, unnamed mode used implicitly on xsl:apply-templates must be declared</description>
+      <created by="Michael Kay" on="2015-08-19"/>     
+      <test>
+         <stylesheet file="declared-modes-008.xsl"/>
+         <initial-template name="main"/>
+      </test>
+      <result>
+         <error code="XTSE3085"/>
+      </result>
+   </test-case>
+   
+   <test-case name="declared-modes-009">
+      <description>With declared-modes='no' within a package mode used on xsl:template need not be declared</description>
+      <created by="Michael Kay" on="2015-08-19"/>     
+      <test>
+         <stylesheet file="declared-modes-009.xsl"/>
+         <initial-template name="main"/>
+      </test>
+      <result>
+         <assert>/a</assert>
+      </result>
+   </test-case>
+   
+   <test-case name="declared-modes-010">
+      <description>With declared-modes='no' within a package mode used on xsl:apply-templates need not be declared</description>
+      <created by="Michael Kay" on="2015-08-19"/>     
+      <test>
+         <stylesheet file="declared-modes-010.xsl"/>
+         <initial-template name="main"/>
+      </test>
+      <result>
+         <assert>/a</assert>
+      </result>
+   </test-case>
+   
+   <test-case name="declared-modes-011">
+      <description>With declared-modes='no' within a package, unnamed mode used implicitly on xsl:template need not be declared</description>
+      <created by="Michael Kay" on="2015-08-19"/>     
+      <test>
+         <stylesheet file="declared-modes-011.xsl"/>
+         <initial-template name="main"/>
+      </test>
+      <result>
+         <assert>/a</assert>
+      </result>
+   </test-case>
+   
+   <test-case name="declared-modes-012">
+      <description>With declared-modes='no' within a package, unnamed mode used implicitly on xsl:apply-templates need not be declared</description>
+      <created by="Michael Kay" on="2015-08-19"/>     
+      <test>
+         <stylesheet file="declared-modes-012.xsl"/>
+         <initial-template name="main"/>
+      </test>
+      <result>
+         <assert>/a</assert>
+      </result>
+   </test-case>
+   
+   <test-case name="declared-modes-013">
+      <description>With declared-modes='yes' within a package, #unnamed mode used explicitly on xsl:template must be declared</description>
+      <created by="Michael Kay" on="2015-08-19"/>     
+      <test>
+         <stylesheet file="declared-modes-013.xsl"/>
+         <initial-template name="main"/>
+      </test>
+      <result>
+         <error code="XTSE3085"/>
+      </result>
+   </test-case>
+   
+   <test-case name="declared-modes-014">
+      <description>With declared-modes='yes' within a package, #unnamed mode used explicitly on xsl:apply-templates must be declared</description>
+      <created by="Michael Kay" on="2015-08-19"/>     
+      <test>
+         <stylesheet file="declared-modes-014.xsl"/>
+         <initial-template name="main"/>
+      </test>
+      <result>
+         <error code="XTSE3085"/>
+      </result>
+   </test-case>
+
+
+
+</test-set> 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/attr/declared-modes/declared-modes-001.xsl	Wed Aug 19 18:37:10 2015 +0100
@@ -0,0 +1,16 @@
+<?xml version="1.0"?> 
+<xsl:package xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
+
+  <!-- PURPOSE:  Use of undeclared mode on xsl:template is an error (declared-modes defaults to true). -->
+
+  <xsl:template match="text()" mode="a">
+    <xsl:text>mode-a:</xsl:text>
+    <xsl:value-of select="."/>
+  </xsl:template>
+
+  <xsl:template name="main">
+    <xsl:text>no-mode:</xsl:text>
+    <xsl:value-of select="."/>
+  </xsl:template>
+
+</xsl:package>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/attr/declared-modes/declared-modes-002.xsl	Wed Aug 19 18:37:10 2015 +0100
@@ -0,0 +1,12 @@
+<?xml version="1.0"?> 
+<xsl:package xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="3.0">
+
+  <!-- PURPOSE:  Use of undeclared mode on xsl:apply-templates is an error (declared-modes defaults to true). -->
+
+  <xsl:template name="main">
+    <xsl:text>no-mode:</xsl:text>
+    <xsl:apply-templates select="17" mode="absent"/>
+    <xsl:value-of select="24"/>
+  </xsl:template>
+
+</xsl:package>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/attr/declared-modes/declared-modes-003.xsl	Wed Aug 19 18:37:10 2015 +0100
@@ -0,0 +1,11 @@
+<?xml version="1.0"?> 
+<xsl:package xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="3.0">
+
+  <!-- PURPOSE:  Use of unnamed mode on xsl:template is an error (declared-modes defaults to true). -->
+
+  <xsl:template name="main" match="/">
+    <xsl:text>no-mode:</xsl:text>
+    <xsl:value-of select="24"/>
+  </xsl:template>
+
+</xsl:package>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/attr/declared-modes/declared-modes-004.xsl	Wed Aug 19 18:37:10 2015 +0100
@@ -0,0 +1,12 @@
+<?xml version="1.0"?> 
+<xsl:package xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="3.0">
+
+  <!-- PURPOSE:  Use of unnamed mode on xsl:apply-templates is an error (declared-modes defaults to true). -->
+
+  <xsl:template name="main">
+    <xsl:text>no-mode:</xsl:text>
+    <xsl:apply-templates select="17"/>
+    <xsl:value-of select="24"/>
+  </xsl:template>
+
+</xsl:package>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/attr/declared-modes/declared-modes-005.xsl	Wed Aug 19 18:37:10 2015 +0100
@@ -0,0 +1,17 @@
+<?xml version="1.0"?> 
+<xsl:package xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"
+declared-modes='true'>
+
+  <!-- PURPOSE:  Use of undeclared mode on xsl:template is an error (declared-modes = true). -->
+
+  <xsl:template match="text()" mode="a">
+    <xsl:text>mode-a:</xsl:text>
+    <xsl:value-of select="."/>
+  </xsl:template>
+
+  <xsl:template name="main">
+    <xsl:text>no-mode:</xsl:text>
+    <xsl:value-of select="."/>
+  </xsl:template>
+
+</xsl:package>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/attr/declared-modes/declared-modes-006.xsl	Wed Aug 19 18:37:10 2015 +0100
@@ -0,0 +1,13 @@
+<?xml version="1.0"?> 
+<xsl:package xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="3.0"
+declared-modes=' yes '>
+
+  <!-- PURPOSE:  Use of undeclared mode on xsl:apply-templates is an error (declared-modes = true). -->
+
+  <xsl:template name="main">
+    <xsl:text>no-mode:</xsl:text>
+    <xsl:apply-templates select="17" mode="absent"/>
+    <xsl:value-of select="24"/>
+  </xsl:template>
+
+</xsl:package>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/attr/declared-modes/declared-modes-007.xsl	Wed Aug 19 18:37:10 2015 +0100
@@ -0,0 +1,12 @@
+<?xml version="1.0"?> 
+<xsl:package xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="3.0"
+declared-modes='1'>
+
+  <!-- PURPOSE:  Use of unnamed mode on xsl:template is an error (declared-modes = true). -->
+
+  <xsl:template name="main" match="/">
+    <xsl:text>no-mode:</xsl:text>
+    <xsl:value-of select="24"/>
+  </xsl:template>
+
+</xsl:package>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/attr/declared-modes/declared-modes-008.xsl	Wed Aug 19 18:37:10 2015 +0100
@@ -0,0 +1,13 @@
+<?xml version="1.0"?> 
+<xsl:package xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="3.0"
+declared-modes='yes'>
+
+  <!-- PURPOSE:  Use of unnamed mode on xsl:apply-templates is an error (declared-modes = true). -->
+
+  <xsl:template name="main">
+    <xsl:text>no-mode:</xsl:text>
+    <xsl:apply-templates select="17"/>
+    <xsl:value-of select="24"/>
+  </xsl:template>
+
+</xsl:package>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/attr/declared-modes/declared-modes-009.xsl	Wed Aug 19 18:37:10 2015 +0100
@@ -0,0 +1,16 @@
+<?xml version="1.0"?> 
+<xsl:package xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"
+declared-modes='false'>
+
+  <!-- PURPOSE:  Use of undeclared mode on xsl:template is not an error (declared-modes = false). -->
+
+  <xsl:template match="text()" mode="a">
+    <xsl:text>mode-a:</xsl:text>
+    <xsl:value-of select="."/>
+  </xsl:template>
+
+  <xsl:template name="main">
+    <a/>
+  </xsl:template>
+
+</xsl:package>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/attr/declared-modes/declared-modes-010.xsl	Wed Aug 19 18:37:10 2015 +0100
@@ -0,0 +1,12 @@
+<?xml version="1.0"?> 
+<xsl:package xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="3.0"
+declared-modes=' no '>
+
+  <!-- PURPOSE:  Use of undeclared mode on xsl:apply-templates is not an error (declared-modes = false). -->
+
+  <xsl:template name="main">
+    <xsl:apply-templates select="()" mode="absent"/>
+    <a/>
+  </xsl:template>
+
+</xsl:package>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/attr/declared-modes/declared-modes-011.xsl	Wed Aug 19 18:37:10 2015 +0100
@@ -0,0 +1,11 @@
+<?xml version="1.0"?> 
+<xsl:package xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="3.0"
+declared-modes='0'>
+
+  <!-- PURPOSE:  Use of unnamed mode on xsl:template is not an error (declared-modes = false). -->
+
+  <xsl:template name="main" match="/">
+    <a/>
+  </xsl:template>
+
+</xsl:package>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/attr/declared-modes/declared-modes-012.xsl	Wed Aug 19 18:37:10 2015 +0100
@@ -0,0 +1,12 @@
+<?xml version="1.0"?> 
+<xsl:package xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="3.0"
+declared-modes='no'>
+
+  <!-- PURPOSE:  Use of unnamed mode on xsl:apply-templates is an error (declared-modes = true). -->
+
+  <xsl:template name="main">
+    <xsl:apply-templates select="()"/>
+    <a/>
+  </xsl:template>
+
+</xsl:package>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/attr/declared-modes/declared-modes-013.xsl	Wed Aug 19 18:37:10 2015 +0100
@@ -0,0 +1,16 @@
+<?xml version="1.0"?> 
+<xsl:package xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"
+declared-modes='true'>
+
+  <!-- PURPOSE:  Use of undeclared mode on xsl:template is an error (declared-modes = true). -->
+
+  <xsl:template match="text()" mode="#unnamed">
+    <xsl:text>mode-a:</xsl:text>
+    <xsl:value-of select="."/>
+  </xsl:template>
+
+  <xsl:template name="main">
+    <a/>
+  </xsl:template>
+
+</xsl:package>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/attr/declared-modes/declared-modes-014.xsl	Wed Aug 19 18:37:10 2015 +0100
@@ -0,0 +1,12 @@
+<?xml version="1.0"?> 
+<xsl:package xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="3.0"
+declared-modes=' yes '>
+
+  <!-- PURPOSE:  Use of undeclared mode on xsl:apply-templates is an error (declared-modes = true). -->
+
+  <xsl:template name="main">
+    <xsl:apply-templates select="()" mode="#unnamed"/>
+    <a/>
+  </xsl:template>
+
+</xsl:package>