New tests for tunnel parameters in streamed template rules
authorMichael Kay <mike@saxonica.com>
Tue, 24 Apr 2018 17:13:30 +0100
changeset 1840 f15c91c9fb6b
parent 1839 2437cf2091dc
child 1841 7b1b1f77a2d8
New tests for tunnel parameters in streamed template rules
tests/strm/si-apply-templates/_si-apply-templates-test-set.xml
tests/strm/si-apply-templates/si-apply-templates-008.xml
tests/strm/si-apply-templates/si-apply-templates-008.xsl
tests/strm/si-apply-templates/si-apply-templates-009.xsl
--- a/tests/strm/si-apply-templates/_si-apply-templates-test-set.xml	Tue Apr 24 17:12:39 2018 +0100
+++ b/tests/strm/si-apply-templates/_si-apply-templates-test-set.xml	Tue Apr 24 17:13:30 2018 +0100
@@ -152,5 +152,43 @@
       </result>
    </test-case>
    
+   <test-case name="si-apply-templates-008">
+      <description>Test that tunnel and non-tunnel parameters are passed to a streamed template processing an attribute node
+         invoked from a built-in template rule with on-no-match="shallow-copy".
+         From a Saxon bug report by Martin Honnen.</description>
+      <created by="Michael Kay" on="2018-04-09"/>
+      <environment>
+         <source role="." streaming="true" file="si-apply-templates-008.xml"/>
+      </environment>
+      <test>
+         <stylesheet file="si-apply-templates-008.xsl"/>
+      </test>
+      <result>
+         <all-of>
+            <assert>/ws/w[1]/@id = '[w_1]'</assert>
+            <assert>/ws/w[8]/@id = '[w_8]'</assert>
+         </all-of>
+      </result>
+   </test-case>
+   
+   <test-case name="si-apply-templates-009">
+      <description>Test that tunnel and non-tunnel parameters are passed to a streamed template processing a text node
+         invoked from a built-in template rule with on-no-match="shallow-copy".
+         From a Saxon bug report by Martin Honnen.</description>
+      <created by="Michael Kay" on="2018-04-09"/>
+      <environment>
+         <source role="." streaming="true" file="si-apply-templates-008.xml"/>
+      </environment>
+      <test>
+         <stylesheet file="si-apply-templates-009.xsl"/>
+      </test>
+      <result>
+         <all-of>
+            <assert>/ws/w[1] = '[how]'</assert>
+            <assert>/ws/w[8] = '[.]'</assert>
+         </all-of>
+      </result>
+   </test-case>
+   
 
 </test-set>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/strm/si-apply-templates/si-apply-templates-008.xml	Tue Apr 24 17:13:30 2018 +0100
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ws>
+    <w id="w_1">how</w>
+    <w id="w_2">to</w>
+    <w id="w_3">add</w>
+    <w id="w_4">document</w>
+    <w id="w_5">number</w>
+    <w id="w_6">to</w>
+    <w id="w_7">this</w>
+    <w id="w_8">.</w>
+</ws>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/strm/si-apply-templates/si-apply-templates-008.xsl	Tue Apr 24 17:13:30 2018 +0100
@@ -0,0 +1,25 @@
+<?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:math="http://www.w3.org/2005/xpath-functions/math" 
+    exclude-result-prefixes="xs math" 
+    version="3.0">
+    
+    <xsl:param name="STREAMABLE" static="yes" as="xs:boolean" select="true()"/>
+    
+    <xsl:mode on-no-match="shallow-copy" _streamable="{$STREAMABLE}"/>
+    
+    <xsl:template match="/">
+        <xsl:apply-templates>
+            <xsl:with-param name="prefix" tunnel="no" as="xs:string" select="'['"/>
+            <xsl:with-param name="suffix" tunnel="yes" as="xs:string" select="']'"/>
+        </xsl:apply-templates>
+    </xsl:template>
+    
+    <xsl:template match="w/@id">
+        <xsl:param name="prefix" tunnel="no"/>
+        <xsl:param name="suffix" tunnel="yes"/>
+        <xsl:attribute name="{name()}" select="$prefix || . || $suffix"/>
+    </xsl:template>
+    
+</xsl:stylesheet>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/strm/si-apply-templates/si-apply-templates-009.xsl	Tue Apr 24 17:13:30 2018 +0100
@@ -0,0 +1,25 @@
+<?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:math="http://www.w3.org/2005/xpath-functions/math" 
+    exclude-result-prefixes="xs math" 
+    version="3.0">
+    
+    <xsl:param name="STREAMABLE" static="yes" as="xs:boolean" select="true()"/>
+    
+    <xsl:mode on-no-match="shallow-copy" _streamable="{$STREAMABLE}"/>
+    
+    <xsl:template match="/">
+        <xsl:apply-templates>
+            <xsl:with-param name="prefix" tunnel="no" as="xs:string" select="'['"/>
+            <xsl:with-param name="suffix" tunnel="yes" as="xs:string" select="']'"/>
+        </xsl:apply-templates>
+    </xsl:template>
+    
+    <xsl:template match="w/text()">
+        <xsl:param name="prefix" tunnel="no"/>
+        <xsl:param name="suffix" tunnel="yes"/>
+        <xsl:value-of select="$prefix || . || $suffix"/>
+    </xsl:template>
+    
+</xsl:stylesheet>
\ No newline at end of file