Add more streaming tests for fn:snapshot()
authorMichael Kay <mike@saxonica.com>
Sat, 30 Aug 2014 11:51:31 +0100
changeset 645 e80583b67464
parent 644 3084e6cff8a6
child 646 1a0e73a2e865
Add more streaming tests for fn:snapshot()
tests/strm/sf-snapshot/_sf-snapshot-test-set.xml
tests/strm/sf-snapshot/sf-snapshot-A.xsl
--- a/tests/strm/sf-snapshot/_sf-snapshot-test-set.xml	Sat Aug 30 11:39:37 2014 +0100
+++ b/tests/strm/sf-snapshot/_sf-snapshot-test-set.xml	Sat Aug 30 11:51:31 2014 +0100
@@ -31,6 +31,10 @@
 ]]></content>
       </source>
    </environment>
+   
+   <environment name="sf-snapshot-A">
+     <stylesheet file="sf-snapshot-A.xsl"/>
+   </environment>
 
 
    <dependencies>
@@ -315,6 +319,133 @@
 ]]></assert-xml>
          </all-of>
       </result>
-   </test-case>       
+   </test-case>
+   
+   <test-case name="sf-snapshot-0303">
+      <description>Use fn:snapshot: climbing posture</description>
+      <created by="Michael Kay" on="2014-08-30"/>
+      <environment ref="sf-snapshot-A"/>
+      <test>
+         <initial-template name="cy-003"/>
+      </test>
+      <result>
+         <assert>/out = "-15.00 -5.00 -2.33 -248.05"</assert>
+      </result>
+   </test-case>
+   
+   <test-case name="sf-snapshot-0304">
+      <description>Use fn:snapshot: climbing posture</description>
+      <created by="Michael Kay" on="2014-08-30"/>
+      <environment ref="sf-snapshot-A"/>
+      <test>
+         <initial-template name="cy-004"/>
+      </test>
+      <result>
+         <assert>/out = "-15.00 -5.00 -2.33 -248.05 101 102"</assert>
+      </result>
+   </test-case>
+   
+   <test-case name="sf-snapshot-0305">
+      <description>Use fn:snapshot: striding posture, element nodes</description>
+      <created by="Michael Kay" on="2014-08-30"/>
+      <environment ref="sf-snapshot-A"/>
+      <test>
+         <initial-template name="cy-005"/>
+      </test>
+      <result>
+         <assert-xml><![CDATA[<out><PRICE>4.95</PRICE><PRICE>6.58</PRICE><PRICE>4.95</PRICE><PRICE>4.95</PRICE><PRICE>16.47</PRICE><PRICE>16.47</PRICE></out>]]></assert-xml>
+      </result>
+   </test-case>
+   
+   <test-case name="sf-snapshot-0306">
+      <description>Use fn:snapshot: striding posture, text nodes</description>
+      <created by="Michael Kay" on="2014-08-30"/>
+      <environment ref="sf-snapshot-A"/>
+      <test>
+         <initial-template name="cy-006"/>
+      </test>
+      <result>
+         <assert>/out = "4.956.584.954.9516.4716.47"</assert>
+      </result>
+   </test-case>
+   
+   <test-case name="sf-snapshot-0308">
+      <description>Use fn:snapshot: striding posture, element nodes plus grounded elements</description>
+      <created by="Michael Kay" on="2014-08-30"/>
+      <environment ref="sf-snapshot-A"/>
+      <test>
+         <initial-template name="cy-008"/>
+      </test>
+      <result>
+         <assert-xml><![CDATA[<out><PRICE>100.00</PRICE><PRICE>101.00</PRICE><PRICE>4.95</PRICE><PRICE>6.58</PRICE><PRICE>4.95</PRICE><PRICE>4.95</PRICE><PRICE>16.47</PRICE><PRICE>16.47</PRICE></out>]]></assert-xml>
+      </result>
+   </test-case>
+   
+   <test-case name="sf-snapshot-0309">
+      <description>Use fn:snapshot: descendant text nodes</description>
+      <created by="Michael Kay" on="2014-08-30"/>
+      <environment ref="sf-snapshot-A"/>
+      <test>
+         <initial-template name="cy-009"/>
+      </test>
+      <result>
+         <assert>/out = "4.956.584.954.9516.4716.47"</assert>
+      </result>
+   </test-case>
+   
+   <test-case name="sf-snapshot-0311">
+      <description>Use fn:snapshot: whole document unchanged</description>
+      <created by="Michael Kay" on="2014-08-30"/>
+      <environment ref="sf-snapshot-A"/>
+      <test>
+         <initial-template name="cy-011"/>
+      </test>
+      <result>
+         <all-of>
+           <assert>/out/head</assert>
+           <assert>/out/BOOKLIST/BOOKS</assert>
+           <assert>/out/BOOKLIST/CATEGORIES</assert>
+           <assert>/out/tail</assert>
+         </all-of>  
+      </result>
+   </test-case>
+   
+   <test-case name="sf-snapshot-0321">
+      <description>Use fn:snapshot: test that namespaces are copied</description>
+      <created by="Michael Kay" on="2014-08-30"/>
+      <environment ref="sf-snapshot-A"/>
+      <test>
+         <initial-template name="cy-021"/>
+      </test>
+      <result>
+         <assert>count(in-scope-prefixes(/out/*)) = 8</assert>
+      </result>
+   </test-case>
+   
+   <test-case name="sf-snapshot-0325">
+      <description>Use fn:snapshot: test that namespaces are copied, argument grounded and consuming</description>
+      <created by="Michael Kay" on="2014-08-30"/>
+      <environment ref="sf-snapshot-A"/>
+      <test>
+         <initial-template name="cy-025"/>
+      </test>
+      <result>
+         <assert>count(in-scope-prefixes(/out/*)) = 8</assert>
+      </result>
+   </test-case>
+   
+   <test-case name="sf-snapshot-0327">
+      <description>Use fn:snapshot: argument crawling and consuming, nested nodes</description>
+      <created by="Michael Kay" on="2014-08-30"/>
+      <environment ref="sf-snapshot-A"/>
+      <test>
+         <initial-template name="cy-027"/>
+      </test>
+      <result>
+         <assert-xml><![CDATA[<out><n><n>1</n><n>2</n><n>3</n><n>4</n><n>5</n></n><n>1</n><n>2</n><n>3</n><n>4</n><n>5</n></out>]]></assert-xml>
+      </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-snapshot/sf-snapshot-A.xsl	Sat Aug 30 11:51:31 2014 +0100
@@ -0,0 +1,127 @@
+<xsl:transform 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">
+    
+    <xsl:variable name="RUN" select="true()" static="yes"/>
+    <xsl:strip-space elements="*"/>
+   
+
+  <!-- within xsl:stream, use fn:snapshot(): climbing posture -->
+  
+  <xsl:template name="cy-003" use-when="$RUN">
+    <out>
+      <xsl:stream href="../docs/transactions.xml">
+        <xsl:variable name="atts" as="attribute(*)*">
+          <xsl:sequence select="snapshot(account/transaction[@value &lt; 0]/@value)"/>
+        </xsl:variable>
+        <xsl:copy-of select="data($atts)"/>  
+      </xsl:stream>
+    </out>
+  </xsl:template>
+  
+  <!-- within xsl:stream, use fn:snapshot(): climbing posture -->
+  
+  <xsl:template name="cy-004" use-when="$RUN">
+    <xsl:variable name="extra" as="element()*">
+      <PRICE value="101"/>
+      <PRICE value="102"/>
+    </xsl:variable>
+    <out>
+      <xsl:stream href="../docs/transactions.xml">
+        <xsl:variable name="atts" as="attribute(*)*">
+          <xsl:sequence select="snapshot((account/transaction[@value &lt; 0]/@value, $extra/@value))"/>
+        </xsl:variable>
+        <xsl:copy-of select="data($atts)"/> 
+      </xsl:stream>
+    </out>
+  </xsl:template>
+  
+  <!-- within xsl:stream, use fn:snapshot(): striding posture, element nodes -->
+  
+  <xsl:template name="cy-005" use-when="$RUN">
+    <out>
+      <xsl:stream href="../docs/books.xml">
+        <xsl:sequence select="snapshot(/BOOKLIST/BOOKS/ITEM/PRICE)"/>
+      </xsl:stream>
+    </out>
+  </xsl:template>
+  
+  <!-- within xsl:stream, use fn:snapshot(): striding posture, text nodes -->
+  
+  <xsl:template name="cy-006" use-when="$RUN">
+    <out>
+      <xsl:stream href="../docs/books.xml">
+        <xsl:sequence select="snapshot(/BOOKLIST/BOOKS/ITEM/PRICE/text())"/>
+      </xsl:stream>
+    </out>
+  </xsl:template>
+  
+  <!-- within xsl:stream, use fn:snapshot(): striding posture, element nodes mixed with grounded elements -->
+  
+  <xsl:template name="cy-008" use-when="$RUN">
+    <xsl:variable name="extra" as="element()*">
+      <PRICE>100.00</PRICE>
+      <PRICE>101.00</PRICE>
+    </xsl:variable>
+    <out>
+      <xsl:stream href="../docs/books.xml">
+        <xsl:sequence select="snapshot(($extra, /BOOKLIST/BOOKS/ITEM/PRICE))"/>
+      </xsl:stream>
+    </out>
+  </xsl:template>
+  
+  <!-- within xsl:stream, use fn:snapshot(): descendant text nodes -->
+  
+  <xsl:template name="cy-009" use-when="$RUN">
+    <out>
+      <xsl:stream href="../docs/books.xml">
+        <xsl:sequence select="snapshot(//PRICE/text())"/>
+      </xsl:stream>
+    </out>
+  </xsl:template>
+  
+  <!-- within xsl:stream, use fn:snapshot(): whole document unchanged -->
+  
+  <xsl:template name="cy-011" use-when="$RUN">
+    <out>
+      <xsl:stream href="../docs/books.xml">
+        <head/>
+        <xsl:sequence select="snapshot(.)"/>
+        <tail/>
+      </xsl:stream>
+    </out>
+  </xsl:template>
+  
+  <!-- within xsl:stream, use fn:snapshot(): copy-namespaces=yes -->
+  
+  <xsl:template name="cy-021" use-when="$RUN">
+    <out>
+      <xsl:stream href="../docs/citygml.xml">
+        <xsl:sequence select="snapshot(/*/*:description)"/>
+      </xsl:stream>
+    </out>
+  </xsl:template>
+  
+  <!-- within xsl:stream, use fn:snapshot(): copy-namespaces="yes", argument grounded and consuming -->
+  
+  <xsl:template name="cy-025" use-when="$RUN">
+    <out>
+      <xsl:stream href="../docs/citygml.xml">
+        <xsl:sequence select="snapshot(snapshot(/*/*:description))"/>
+      </xsl:stream>
+    </out>
+  </xsl:template>
+  
+  <!-- within xsl:stream, use fn:snapshot(): argument crawling and consuming, nested nodes -->
+  
+  <xsl:template name="cy-027" use-when="$RUN">
+    <out>
+      <xsl:stream href="../docs/nested-numbers.xml">
+        <xsl:sequence select="snapshot(descendant::n)"/>
+      </xsl:stream>
+    </out>
+  </xsl:template>
+  
+</xsl:transform>  
\ No newline at end of file