Add tests for current() in supposedly streamable patterns
authorMichael Kay <mike@saxonica.com>
Sun, 14 Feb 2016 09:03:16 +0000
changeset 1243 663ee4c866e8
parent 1242 6dcc7f162584
child 1244 53276de9d6d0
child 1245 d83bf28462d5
Add tests for current() in supposedly streamable patterns
tests/strm/sf-current/_sf-current-test-set.xml
tests/strm/sf-current/sf-current-100.xsl
tests/strm/sf-current/sf-current-902.xsl
tests/strm/sf-current/sf-current-903.xsl
tests/strm/sf-current/sf-current-904.xsl
tests/strm/sf-current/sf-current-905.xsl
--- a/tests/strm/sf-current/_sf-current-test-set.xml	Sun Feb 14 06:50:09 2016 +0000
+++ b/tests/strm/sf-current/_sf-current-test-set.xml	Sun Feb 14 09:03:16 2016 +0000
@@ -97,6 +97,17 @@
          <assert-xml><![CDATA[<out>ITEM ITEM ITEM ITEM ITEM ITEM</out>]]></assert-xml>
       </result>
    </test-case>
+   
+   <test-case name="sf-current-100">
+      <description>Use of current() in motionless match patterns</description>
+      <created by="Michael Kay" on="2016-02-14"/>
+      <test>
+         <stylesheet file="sf-current-100.xsl"/>
+      </test>
+      <result>
+         <assert>not(//ITEM[@CAT="H"]/AUTHOR)</assert>
+      </result>
+   </test-case>
 
  
    <test-case name="sf-current-901">
@@ -109,5 +120,53 @@
       <result>
          <error code="XTSE3430"/>
       </result>
+   </test-case> 
+   
+   <test-case name="sf-current-902">
+      <description>Non-motionless use of current() in a pattern, not streamable.</description>
+      <created by="Michael Kay" on="2016-02-14"/>
+      <test>
+         <stylesheet file="sf-current-902.xsl"/>
+         <initial-template name="main"/>
+      </test>
+      <result>
+         <error code="XTSE3430"/>
+      </result>
+   </test-case>
+
+   <test-case name="sf-current-903">
+      <description>Non-motionless use of current() in a pattern, not streamable.</description>
+      <created by="Michael Kay" on="2016-02-14"/>
+      <test>
+         <stylesheet file="sf-current-903.xsl"/>
+         <initial-template name="main"/>
+      </test>
+      <result>
+         <error code="XTSE3430"/>
+      </result>
+   </test-case>
+
+   <test-case name="sf-current-904">
+      <description>Non-motionless use of current() in a pattern, not streamable.</description>
+      <created by="Michael Kay" on="2016-02-14"/>
+      <test>
+         <stylesheet file="sf-current-904.xsl"/>
+         <initial-template name="main"/>
+      </test>
+      <result>
+         <error code="XTSE3430"/>
+      </result>
+   </test-case> 
+   
+   <test-case name="sf-current-905">
+      <description>Non-motionless use of current() in a pattern, not streamable.</description>
+      <created by="Michael Kay" on="2016-02-14"/>
+      <test>
+         <stylesheet file="sf-current-905.xsl"/>
+         <initial-template name="main"/>
+      </test>
+      <result>
+         <error code="XTSE3430"/>
+      </result>
    </test-case>   
 </test-set>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/strm/sf-current/sf-current-100.xsl	Sun Feb 14 09:03:16 2016 +0000
@@ -0,0 +1,41 @@
+<xsl:stylesheet version="3.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+  xmlns:map="http://www.w3.org/2005/xpath-functions/map" xmlns:xs="http://www.w3.org/2001/XMLSchema"
+  exclude-result-prefixes="map xs"
+  default-mode="m">
+
+  <xsl:variable name="RUN" select="true()" static="yes"/>
+  <xsl:strip-space elements="*"/>
+
+  <!-- correct use of current() in motionless match patterns -->
+
+  <xsl:mode name="m" streamable="yes" on-no-match="shallow-copy"/>
+  
+  <xsl:variable name="cat" select="'MMP'"/>
+
+  <xsl:template name="xsl:initial-template">
+    <xsl:stream href="../docs/books.xml">
+      <out>
+        <xsl:apply-templates/>
+      </out>
+    </xsl:stream>
+  </xsl:template>
+
+  <xsl:template match="ITEM[namespace-uri(current()) = '']">
+    <xsl:next-match/>
+  </xsl:template>
+
+  <xsl:template match="DIMENSIONS[current()/@UNIT='in']">
+    <xsl:next-match/>
+  </xsl:template>
+  
+  <xsl:template match="AUTHOR[current()/../@CAT='H']"/>
+  
+  <xsl:template match="AUTHOR[..[@CAT = current()/../@CAT]]">
+    <xsl:next-match/>
+  </xsl:template>
+  
+  <xsl:template match="*[ancestor::*[node-name(.) = node-name(current())]]" priority="100">
+    <xsl:message terminate="yes">Recursive data found</xsl:message>
+  </xsl:template>
+
+</xsl:stylesheet>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/strm/sf-current/sf-current-902.xsl	Sun Feb 14 09:03:16 2016 +0000
@@ -0,0 +1,41 @@
+<xsl:stylesheet version="3.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+  xmlns:map="http://www.w3.org/2005/xpath-functions/map" xmlns:xs="http://www.w3.org/2001/XMLSchema"
+  exclude-result-prefixes="map xs"
+  default-mode="m">
+
+  <xsl:variable name="RUN" select="true()" static="yes"/>
+  <xsl:strip-space elements="*"/>
+
+  <!-- non-streamable use of current() in match pattern -->
+
+  <xsl:mode name="m" streamable="yes" on-no-match="shallow-copy"/>
+  
+  <xsl:variable name="cat" select="'MMP'"/>
+
+  <xsl:template name="xsl:initial-template">
+    <xsl:stream href="../docs/books.xml">
+      <out>
+        <xsl:apply-templates/>
+      </out>
+    </xsl:stream>
+  </xsl:template>
+
+  <xsl:template match="ITEM[namespace-uri(current()) = '']">
+    <xsl:next-match/>
+  </xsl:template>
+
+  <xsl:template match="AUTHOR[current()='Jasper Fforde']">
+    <xsl:next-match/>
+  </xsl:template>
+  
+  <xsl:template match="AUTHOR[current()/../@CAT='H']"/>
+  
+  <xsl:template match="AUTHOR[..[@CAT = current()/../@CAT]]">
+    <xsl:next-match/>
+  </xsl:template>
+  
+  <xsl:template match="*[ancestor::*[node-name(.) = node-name(current())]]" priority="100">
+    <xsl:message terminate="yes">Recursive data found</xsl:message>
+  </xsl:template>
+
+</xsl:stylesheet>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/strm/sf-current/sf-current-903.xsl	Sun Feb 14 09:03:16 2016 +0000
@@ -0,0 +1,41 @@
+<xsl:stylesheet version="3.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+  xmlns:map="http://www.w3.org/2005/xpath-functions/map" xmlns:xs="http://www.w3.org/2001/XMLSchema"
+  exclude-result-prefixes="map xs"
+  default-mode="m">
+
+  <xsl:variable name="RUN" select="true()" static="yes"/>
+  <xsl:strip-space elements="*"/>
+
+  <!-- non-streamable use of current() in match pattern -->
+
+  <xsl:mode name="m" streamable="yes" on-no-match="shallow-copy"/>
+  
+  <xsl:variable name="cat" select="'MMP'"/>
+
+  <xsl:template name="xsl:initial-template">
+    <xsl:stream href="../docs/books.xml">
+      <out>
+        <xsl:apply-templates/>
+      </out>
+    </xsl:stream>
+  </xsl:template>
+
+  <xsl:template match="ITEM[namespace-uri(current()) = '']">
+    <xsl:next-match/>
+  </xsl:template>
+
+  <xsl:template match="AUTHOR[current()/text()='Jasper Fforde']">
+    <xsl:next-match/>
+  </xsl:template>
+  
+  <xsl:template match="AUTHOR[current()/../@CAT='H']"/>
+  
+  <xsl:template match="AUTHOR[..[@CAT = current()/../@CAT]]">
+    <xsl:next-match/>
+  </xsl:template>
+  
+  <xsl:template match="*[ancestor::*[node-name(.) = node-name(current())]]" priority="100">
+    <xsl:message terminate="yes">Recursive data found</xsl:message>
+  </xsl:template>
+
+</xsl:stylesheet>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/strm/sf-current/sf-current-904.xsl	Sun Feb 14 09:03:16 2016 +0000
@@ -0,0 +1,41 @@
+<xsl:stylesheet version="3.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+  xmlns:map="http://www.w3.org/2005/xpath-functions/map" xmlns:xs="http://www.w3.org/2001/XMLSchema"
+  exclude-result-prefixes="map xs"
+  default-mode="m">
+
+  <xsl:variable name="RUN" select="true()" static="yes"/>
+  <xsl:strip-space elements="*"/>
+
+  <!-- non-streamable use of current() in match pattern -->
+
+  <xsl:mode name="m" streamable="yes" on-no-match="shallow-copy"/>
+  
+  <xsl:variable name="cat" select="'MMP'"/>
+
+  <xsl:template name="xsl:initial-template">
+    <xsl:stream href="../docs/books.xml">
+      <out>
+        <xsl:apply-templates/>
+      </out>
+    </xsl:stream>
+  </xsl:template>
+
+  <xsl:template match="ITEM[namespace-uri(current()) = '']">
+    <xsl:next-match/>
+  </xsl:template>
+
+  <xsl:template match="AUTHOR[current()/data()='Jasper Fforde']">
+    <xsl:next-match/>
+  </xsl:template>
+  
+  <xsl:template match="AUTHOR[current()/../@CAT='H']"/>
+  
+  <xsl:template match="AUTHOR[..[@CAT = current()/../@CAT]]">
+    <xsl:next-match/>
+  </xsl:template>
+  
+  <xsl:template match="*[ancestor::*[node-name(.) = node-name(current())]]" priority="100">
+    <xsl:message terminate="yes">Recursive data found</xsl:message>
+  </xsl:template>
+
+</xsl:stylesheet>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/strm/sf-current/sf-current-905.xsl	Sun Feb 14 09:03:16 2016 +0000
@@ -0,0 +1,41 @@
+<xsl:stylesheet version="3.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+  xmlns:map="http://www.w3.org/2005/xpath-functions/map" xmlns:xs="http://www.w3.org/2001/XMLSchema"
+  exclude-result-prefixes="map xs"
+  default-mode="m">
+
+  <xsl:variable name="RUN" select="true()" static="yes"/>
+  <xsl:strip-space elements="*"/>
+
+  <!-- non-streamable use of current() in match pattern -->
+
+  <xsl:mode name="m" streamable="yes" on-no-match="shallow-copy"/>
+  
+  <xsl:variable name="cat" select="'MMP'"/>
+
+  <xsl:template name="xsl:initial-template">
+    <xsl:stream href="../docs/books.xml">
+      <out>
+        <xsl:apply-templates/>
+      </out>
+    </xsl:stream>
+  </xsl:template>
+
+  <xsl:template match="ITEM[namespace-uri(current()) = '']">
+    <xsl:next-match/>
+  </xsl:template>
+
+  <xsl:template match="AUTHOR[parent::ITEM[current()/data()='Jasper Fforde']]">
+    <xsl:next-match/>
+  </xsl:template>
+  
+  <xsl:template match="AUTHOR[current()/../@CAT='H']"/>
+  
+  <xsl:template match="AUTHOR[..[@CAT = current()/../@CAT]]">
+    <xsl:next-match/>
+  </xsl:template>
+  
+  <xsl:template match="*[ancestor::*[node-name(.) = node-name(current())]]" priority="100">
+    <xsl:message terminate="yes">Recursive data found</xsl:message>
+  </xsl:template>
+
+</xsl:stylesheet>