Test for streaming xsl:apply-templates with extended rule sets for text nodes
authorMichael Kay <mike@saxonica.com>
Tue, 11 Sep 2018 15:07:04 +0100
changeset 1892 043fdfaa9c5c
parent 1891 13bd2061eeae
child 1893 6378e52dfdf2
Test for streaming xsl:apply-templates with extended rule sets for text nodes
tests/strm/si-apply-templates/_si-apply-templates-test-set.xml
tests/strm/si-apply-templates/si-apply-templates-010.xml
tests/strm/si-apply-templates/si-apply-templates-010.xsl
tests/strm/si-apply-templates/si-apply-templates-011.xsl
--- a/tests/strm/si-apply-templates/_si-apply-templates-test-set.xml	Tue Sep 11 15:06:31 2018 +0100
+++ b/tests/strm/si-apply-templates/_si-apply-templates-test-set.xml	Tue Sep 11 15:07:04 2018 +0100
@@ -190,5 +190,41 @@
       </result>
    </test-case>
    
+   <test-case name="si-apply-templates-010">
+      <description>Large set of streamable template rules all matching text nodes. Saxon bug 3901, based on 
+         StackOverflow question 52259180 by user Jerome.</description>
+      <created by="Michael Kay" on="2018-09-10"/>
+      <environment>
+         <source role="." streaming="true" file="si-apply-templates-010.xml"/>
+      </environment>
+      <test>
+         <stylesheet file="si-apply-templates-010.xsl"/>
+      </test>
+      <result>
+         <all-of>
+            <assert>//id = "10_ID"</assert>
+            <assert>//id = "9_ID"</assert>
+         </all-of>
+      </result>
+   </test-case>
+   
+   <test-case name="si-apply-templates-011">
+      <description>Large set of streamable template rules all matching text nodes. Same as -010, but with a much larger set of
+         template rules, most of which will never match anything.</description>
+      <created by="Michael Kay" on="2018-09-10"/>
+      <environment>
+         <source role="." streaming="true" file="si-apply-templates-010.xml"/>
+      </environment>
+      <test>
+         <stylesheet file="si-apply-templates-011.xsl"/>
+      </test>
+      <result>
+         <all-of>
+            <assert>//id = "10_ID"</assert>
+            <assert>//id = "9_ID"</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-010.xml	Tue Sep 11 15:07:04 2018 +0100
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<table>
+    <row>
+        <id>10</id>
+        <email>fake@fake.com</email>
+        <address>dsffe</address>
+        <birthday>10/2018</birthday>
+        <country>FR</country>
+        <external>zz</external>
+        <internal>ww</internal>
+        <name>Jean</name>
+        <phone>000000</phone>
+        <city>Dfegd</city>
+    </row>
+    <row>
+        <id>9</id>
+        <email>fake@fake2.com</email>
+        <address>sdfzefzef</address>
+        <birthday>11/2012</birthday>
+        <country>GB</country>
+        <external>xx</external>
+        <internal>yy</internal>
+        <name>Jean-Claude</name>
+        <phone>000000</phone>
+        <city>dd</city>
+    </row>
+</table>
\ 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-010.xsl	Tue Sep 11 15:07:04 2018 +0100
@@ -0,0 +1,40 @@
+<xsl:stylesheet version="3.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+  <xsl:mode streamable="yes"/>
+  <xsl:output method="xml"/>
+  <xsl:template match="email/text()">
+    <xsl:value-of select="current()"/>
+  </xsl:template>
+  <xsl:template match="address/text()">
+    <xsl:value-of select="current()"/>
+  </xsl:template>
+  <xsl:template match="birthday/text()">
+    <xsl:value-of select="current()"/>
+  </xsl:template>
+  <xsl:template match="country/text()">
+    <xsl:value-of select="current()"/>
+  </xsl:template>
+  <xsl:template match="external/text()">
+    <xsl:value-of select="current()"/>
+  </xsl:template>
+  <xsl:template match="internal/text()">
+    <xsl:value-of select="current()"/>
+  </xsl:template>
+  <xsl:template match="name/text()">
+    <xsl:value-of select="current()"/>
+  </xsl:template>
+  <xsl:template match="phone/text()">
+    <xsl:value-of select="current()"/>
+  </xsl:template>
+  <xsl:template match="city/text()">
+    <xsl:value-of select="current()"/>
+  </xsl:template>
+  <xsl:template match="id/text()">
+    <xsl:value-of select="concat(current(), '_ID')"/>
+  </xsl:template>
+  <xsl:template match=".">
+    <xsl:copy validation="preserve">
+      <xsl:apply-templates select="@*"/>
+      <xsl:apply-templates select="node()"/>
+    </xsl:copy>
+  </xsl:template>
+</xsl:stylesheet>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/strm/si-apply-templates/si-apply-templates-011.xsl	Tue Sep 11 15:07:04 2018 +0100
@@ -0,0 +1,120 @@
+<xsl:stylesheet version="3.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+  <xsl:mode streamable="yes"/>
+  <xsl:output method="xml"/>
+  
+  <!-- This test is designed to exercise implementations that attempt to be smarter in their
+    strategy for rule evaluation than simply testing each rule in turn. -->
+  
+  <xsl:template match="email/text()">
+    <xsl:value-of select="current()"/>
+  </xsl:template>
+  <xsl:template match="email/text()[. = 'abcde']"/>
+  <xsl:template match="email/text()[. = 'abcde2']"/>
+  <xsl:template match="email/text()[. = 'abcde3']"/>
+  <xsl:template match="email/text()[. = 'abcde4']"/>
+  <xsl:template match="email/text()[. = 'abcde5']"/>
+  <xsl:template match="email/text()[. = 'abcde6']"/>
+  
+  <xsl:template match="address/text()">
+    <xsl:value-of select="current()"/>
+  </xsl:template>
+  <xsl:template match="address/text()[. = 'abcde']"/>
+  <xsl:template match="address/text()[. = 'abcde2']"/>
+  <xsl:template match="address/text()[. = 'abcde3']"/>
+  <xsl:template match="address/text()[. = 'abcde4']"/>
+  <xsl:template match="address/text()[. = 'abcde5']"/>
+  <xsl:template match="address/text()[. = 'abcde6']"/>
+  <xsl:template match="address/text()[. = 'abcde7']"/>
+  
+  <xsl:template match="birthday/text()">
+    <xsl:value-of select="current()"/>
+  </xsl:template>
+  <xsl:template match="birthday/text()[. = 'abcde']"/>
+  <xsl:template match="birthday/text()[. = 'abcde2']"/>
+  <xsl:template match="birthday/text()[. = 'abcde3']"/>
+  <xsl:template match="birthday/text()[. = 'abcde4']"/>
+  <xsl:template match="birthday/text()[. = 'abcde5']"/>
+  <xsl:template match="birthday/text()[. = 'abcde6']"/>
+  <xsl:template match="birthday/text()[. = 'abcde7']"/>
+  
+  <xsl:template match="country/text()">
+    <xsl:value-of select="current()"/>
+  </xsl:template>
+  <xsl:template match="country/text()[. = 'abcde']"/>
+  <xsl:template match="country/text()[. = 'abcde2']"/>
+  <xsl:template match="country/text()[. = 'abcde3']"/>
+  <xsl:template match="country/text()[. = 'abcde4']"/>
+  <xsl:template match="country/text()[. = 'abcde5']"/>
+  <xsl:template match="country/text()[. = 'abcde6']"/>
+  <xsl:template match="country/text()[. = 'abcde7']"/>
+  <xsl:template match="country/text()[. = 'abcde8']"/>
+  
+  <xsl:template match="external/text()">
+    <xsl:value-of select="current()"/>
+  </xsl:template>
+  <xsl:template match="external/text()[. = 'abcde']"/>
+  <xsl:template match="external/text()[. = 'abcde2']"/>
+  <xsl:template match="external/text()[. = 'abcde3']"/>
+  <xsl:template match="external/text()[. = 'abcde4']"/>
+  <xsl:template match="external/text()[. = 'abcde5']"/>
+  <xsl:template match="external/text()[. = 'abcde6']"/>
+  
+  <xsl:template match="internal/text()">
+    <xsl:value-of select="current()"/>
+  </xsl:template>
+  <xsl:template match="internal/text()[. = 'abcde']"/>
+  <xsl:template match="internal/text()[. = 'abcde2']"/>
+  <xsl:template match="internal/text()[. = 'abcde3']"/>
+  <xsl:template match="internal/text()[. = 'abcde4']"/>
+  <xsl:template match="internal/text()[. = 'abcde5']"/>
+  <xsl:template match="internal/text()[. = 'abcde6']"/>
+  
+  <xsl:template match="name/text()">
+    <xsl:value-of select="current()"/>
+  </xsl:template>
+  <xsl:template match="name/text()[. = 'abcde']"/>
+  <xsl:template match="name/text()[. = 'abcde2']"/>
+  <xsl:template match="name/text()[. = 'abcde3']"/>
+  <xsl:template match="name/text()[. = 'abcde4']"/>
+  <xsl:template match="name/text()[. = 'abcde5']"/>
+  <xsl:template match="name/text()[. = 'abcde6']"/>
+  
+  <xsl:template match="phone/text()">
+    <xsl:value-of select="current()"/>
+  </xsl:template>
+  <xsl:template match="phone/text()[. = 'abcde']"/>
+  <xsl:template match="phone/text()[. = 'abcde2']"/>
+  <xsl:template match="phone/text()[. = 'abcde3']"/>
+  <xsl:template match="phone/text()[. = 'abcde4']"/>
+  <xsl:template match="phone/text()[. = 'abcde5']"/>
+  <xsl:template match="phone/text()[. = 'abcde6']"/>
+  
+  <xsl:template match="city/text()">
+    <xsl:value-of select="current()"/>
+  </xsl:template>
+  <xsl:template match="city/text()[. = 'abcde']"/>
+  <xsl:template match="city/text()[. = 'abcde2']"/>
+  <xsl:template match="city/text()[. = 'abcde3']"/>
+  <xsl:template match="city/text()[. = 'abcde4']"/>
+  <xsl:template match="city/text()[. = 'abcde5']"/>
+  <xsl:template match="city/text()[. = 'abcde6']"/>
+  
+  
+  <xsl:template match="id/text()">
+    <xsl:value-of select="concat(current(), '_ID')"/>
+  </xsl:template>
+  <xsl:template match="id/text()[. = 'abcde']"/>
+  <xsl:template match="id/text()[. = 'abcde2']"/>
+  <xsl:template match="id/text()[. = 'abcde3']"/>
+  <xsl:template match="id/text()[. = 'abcde4']"/>
+  <xsl:template match="id/text()[. = 'abcde5']"/>
+  <xsl:template match="id/text()[. = 'abcde6']"/>
+  
+  
+  <xsl:template match=".">
+    <xsl:copy validation="preserve">
+      <xsl:apply-templates select="@*"/>
+      <xsl:apply-templates select="node()"/>
+    </xsl:copy>
+  </xsl:template>
+</xsl:stylesheet>