New tests for streaming xsl:conditional-content
authorMichael Kay <mike@saxonica.com>
Thu, 02 Jul 2015 22:33:53 +0100
changeset 1004 d5ec1b9d8ad5
parent 1003 0bf0d49fc36e
child 1005 800d6241ce19
New tests for streaming xsl:conditional-content
tests/strm/si-conditional-content/_si-conditional-content-test-set.xml
tests/strm/si-conditional-content/si-conditional-content-A.xsl
--- a/tests/strm/si-conditional-content/_si-conditional-content-test-set.xml	Wed Jul 01 22:02:55 2015 +0100
+++ b/tests/strm/si-conditional-content/_si-conditional-content-test-set.xml	Thu Jul 02 22:33:53 2015 +0100
@@ -2,21 +2,161 @@
 <test-set xmlns="http://www.w3.org/2012/10/xslt-test-catalog" xmlns:xs="http://www.w3.org/2001/XMLSchema" name="si-conditional-content">
    <description>Tests xsl:stream instruction introduced in XSLT 3.0 with xsl:conditional-content.</description>
    
+   <environment name="si-coco-A">
+     <stylesheet file="si-conditional-content-A.xsl"/>
+   </environment>
+   
    <dependencies>
       <spec value="XSLT30+"/>
       <feature value="streaming"/>
    </dependencies>
    
-   <test-case name="si-conditional-content-001">
+   <test-case name="si-coco-001">
+      <description>xsl:element; value is consuming; xsl:conditional-content</description>
+      <created by="Michael Kay" on="2014-01-06"/>
+      <environment ref="si-coco-A"/>
+      <test>
+         <initial-template name="s-001"/>
+      </test>
+      <result>
+         <assert>empty(/out/a)</assert>
+      </result>
+   </test-case>
+   
+   <test-case name="si-coco-002">
       <description>Test of xsl:stream instruction with xsl:conditional-content</description>
-      <created by="Michael Kay" on="2014-12-19"/>  
+      <created by="Michael Kay" on="2014-12-19"/>
+      <environment ref="si-coco-A"/>  
       <test>
-         <stylesheet file="si-conditional-content-001.xsl"/>
-         <initial-template name="main"/>
+         <initial-template name="s-002"/>
       </test>
       <result>
          <assert-xml><![CDATA[<Results><first>one</first><last>last</last></Results>]]></assert-xml>
       </result>
    </test-case>
+   
+   <test-case name="si-coco-003">
+      <description>Test of xsl:conditional-content with atomic values, some 'empty'</description>
+      <created by="Michael Kay" on="2015-07-02"/>
+      <environment ref="si-coco-A"/>  
+      <test>
+         <initial-template name="s-003"/>
+      </test>
+      <result>
+         <assert>/out = "23 2011-01-01 0"</assert>
+      </result>
+   </test-case>
+   
+   <test-case name="si-coco-004">
+      <description>Test of xsl:conditional-content with xsl:if</description>
+      <created by="Michael Kay" on="2015-07-02"/>
+      <environment ref="si-coco-A"/>  
+      <test>
+         <initial-template name="s-004"/>
+      </test>
+      <result>
+         <assert>empty(/out/*)</assert>
+      </result>
+   </test-case>
+   
+   <test-case name="si-coco-005">
+      <description>Test of xsl:conditional-content with xsl:if</description>
+      <created by="Michael Kay" on="2015-07-02"/>
+      <environment ref="si-coco-A"/>  
+      <test>
+         <initial-template name="s-005"/>
+      </test>
+      <result>
+         <assert>exists(/out/a/banana)</assert>
+      </result>
+   </test-case>
+   
+   <test-case name="si-coco-006">
+      <description>Test of xsl:conditional-content with xsl:for-each</description>
+      <created by="Michael Kay" on="2015-07-02"/>
+      <environment ref="si-coco-A"/>  
+      <test>
+         <initial-template name="s-006"/>
+      </test>
+      <result>
+         <assert>exists(/out/ul/li)</assert>
+      </result>
+   </test-case>
+   
+   <test-case name="si-coco-007">
+      <description>Test of xsl:conditional-content with xsl:for-each</description>
+      <created by="Michael Kay" on="2015-07-02"/>
+      <environment ref="si-coco-A"/>  
+      <test>
+         <initial-template name="s-007"/>
+      </test>
+      <result>
+         <assert>empty(/out/node())</assert>
+      </result>
+   </test-case>
+   
+   <test-case name="si-coco-008">
+      <description>Test of xsl:conditional-content with comment nodes</description>
+      <created by="Michael Kay" on="2015-07-02"/>
+      <environment ref="si-coco-A"/>  
+      <test>
+         <initial-template name="s-008"/>
+      </test>
+      <result>
+         <assert>count(/out/in/comment()[.='3']) = 6</assert>
+      </result>
+   </test-case>
+   
+   <test-case name="si-coco-009">
+      <description>Test of xsl:conditional-content with text nodes</description>
+      <created by="Michael Kay" on="2015-07-02"/>
+      <environment ref="si-coco-A"/>  
+      <test>
+         <initial-template name="s-009"/>
+      </test>
+      <result>
+         <assert>count(/out/in[.='3']) = 6</assert>
+      </result>
+   </test-case>
+   
+   <test-case name="si-coco-010">
+      <description>Test of xsl:conditional-content with xsl:fork</description>
+      <created by="Michael Kay" on="2015-07-02"/>
+      <environment ref="si-coco-A"/>  
+      <test>
+         <initial-template name="s-010"/>
+      </test>
+      <result>
+         <assert-xml><![CDATA[<out><TITLE>Pride and Prejudice</TITLE><TITLE>Wuthering Heights</TITLE
+         ><TITLE>Tess of the d'Urbervilles</TITLE><TITLE>Jude the Obscure</TITLE><TITLE>The Big Over Easy</TITLE
+         ><TITLE>The Eyre Affair</TITLE><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="si-coco-011">
+      <description>Test of xsl:conditional-content with xsl:fork</description>
+      <created by="Michael Kay" on="2015-07-02"/>
+      <environment ref="si-coco-A"/>  
+      <test>
+         <initial-template name="s-011"/>
+      </test>
+      <result>
+         <assert>empty(/out/node())</assert>
+      </result>
+   </test-case>
+   
+   <test-case name="si-coco-012">
+      <description>Test of xsl:conditional-content with document nodes</description>
+      <created by="Michael Kay" on="2015-07-02"/>
+      <environment ref="si-coco-A"/>  
+      <test>
+         <initial-template name="s-012"/>
+      </test>
+      <result>
+         <assert>/out/in/@value = 'true'</assert>
+      </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-conditional-content/si-conditional-content-A.xsl	Thu Jul 02 22:33:53 2015 +0100
@@ -0,0 +1,208 @@
+<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:err="http://www.w3.org/2005/xqt-errors" xmlns:xs="http://www.w3.org/2001/XMLSchema"
+  exclude-result-prefixes="map xs err">
+
+  <xsl:variable name="RUN" select="true()" static="yes"/>
+  <xsl:strip-space elements="*"/>
+
+ 
+  <!-- Test of xsl:conditional-content with xsl:element (not empty) -->
+
+  <xsl:template name="s-001" use-when="$RUN">
+    <xsl:stream href="../docs/books.xml">
+      <out>
+        <xsl:conditional-content>
+          <xsl:element name="a">
+            <xsl:sequence select="./BOOKLIST/BOOKS/ITEM/PRICEDATA"/>
+          </xsl:element>
+        </xsl:conditional-content>  
+      </out>
+    </xsl:stream>
+  </xsl:template>
+  
+  <!-- Test of xsl:conditional-content with multiple elements, some empty -->
+  
+  <xsl:template name="s-002" use-when="$RUN">
+       <xsl:stream href="../docs/books.xml">
+           <Results>
+               <xsl:conditional-content>
+                 <first>one</first>
+                 <second/>
+                 <xsl:copy-of select="BOOKLIST/CATEGORIES/*" />
+                 <last>last</last>
+               </xsl:conditional-content>
+           </Results>
+       </xsl:stream>
+   </xsl:template> 
+   
+   <!-- Test of xsl:conditional-content with atomic values, some empty -->
+  
+  <xsl:template name="s-003" use-when="$RUN">
+       <xsl:stream href="../docs/books.xml">
+           <out>
+               <xsl:conditional-content>
+                 <xsl:sequence select="23, '', xs:date('2011-01-01'), xs:untypedAtomic(''), 0, /JUNK, xs:base64Binary('')"/>
+               </xsl:conditional-content>
+           </out>
+       </xsl:stream>
+   </xsl:template>
+   
+   <!-- Test of xsl:conditional-content with xsl:if -->
+
+  <xsl:template name="s-004" use-when="$RUN">
+    <xsl:stream href="../docs/books.xml">
+      <out>
+        <xsl:conditional-content>
+          <a>
+            <xsl:if test="current-date() lt xs:date('1900-01-01')">
+               <banana x="{count(//*)}"/>
+            </xsl:if>
+          </a>
+        </xsl:conditional-content>  
+      </out>
+    </xsl:stream>
+  </xsl:template> 
+  
+  <!-- Test of xsl:conditional-content with xsl:if -->
+
+  <xsl:template name="s-005" use-when="$RUN">
+    <xsl:stream href="../docs/books.xml">
+      <out>
+        <xsl:conditional-content>
+          <a>
+            <xsl:if test="current-date() gt xs:date('1900-01-01')">
+               <banana x="{count(//*)}"/>
+            </xsl:if>
+          </a>
+        </xsl:conditional-content>  
+      </out>
+    </xsl:stream>
+  </xsl:template> 
+  
+  <!-- Test of xsl:conditional-content with xsl:for-each -->
+
+  <xsl:template name="s-006" use-when="$RUN">
+    <xsl:stream href="../docs/books.xml">
+      <out>
+        <xsl:conditional-content>
+          <ul>
+            <xsl:for-each select="outermost(//ITEM)">
+              <li><xsl:value-of select="TITLE"/></li>
+            </xsl:for-each>  
+          </ul>
+        </xsl:conditional-content>  
+      </out>
+    </xsl:stream>
+  </xsl:template> 
+  
+  <!-- Test of xsl:conditional-content with xsl:for-each -->
+
+  <xsl:template name="s-007" use-when="$RUN">
+    <xsl:stream href="../docs/books.xml">
+      <out>
+        <xsl:conditional-content>
+          <ul>
+            <xsl:for-each select="outermost(//MAGAZINE)">
+              <li><xsl:value-of select="TITLE"/></li>
+            </xsl:for-each>  
+          </ul>
+        </xsl:conditional-content>  
+      </out>
+    </xsl:stream>
+  </xsl:template> 
+  
+  <!-- Test of xsl:conditional-content with comment nodes -->
+
+  <xsl:template name="s-008" use-when="$RUN">
+    <xsl:stream href="../docs/books.xml">
+      <out>
+        <xsl:for-each select="outermost(//ITEM)">
+          <in>
+            <xsl:conditional-content>
+              <xsl:comment select="TITLE[parent::BOOK]"/>
+            </xsl:conditional-content>
+            <xsl:conditional-content>
+              <xsl:comment select="count(ancestor::node())"/>
+            </xsl:conditional-content> 
+          </in>  
+         </xsl:for-each>  
+      </out>
+    </xsl:stream>
+  </xsl:template> 
+  
+  <!-- Test of xsl:conditional-content with text nodes -->
+
+  <xsl:template name="s-009" use-when="$RUN">
+    <xsl:stream href="../docs/books.xml">
+      <out>
+        <xsl:for-each select="outermost(//ITEM)">
+          <in>
+            <xsl:conditional-content>
+              <xsl:value-of select="TITLE[parent::BOOK]"/>
+            </xsl:conditional-content>
+            <xsl:conditional-content>
+              <xsl:value-of select="count(ancestor::node())"/>
+            </xsl:conditional-content> 
+          </in>  
+         </xsl:for-each>  
+      </out>
+    </xsl:stream>
+  </xsl:template> 
+  
+  <!-- Test of xsl:conditional-content with xsl:fork -->
+
+  <xsl:template name="s-010" use-when="$RUN">
+    <xsl:stream href="../docs/books.xml">
+      <out>
+        <xsl:conditional-content>
+          <a>
+            <xsl:fork>
+              <xsl:sequence select="copy-of(//TITLE)"/>
+              <xsl:sequence select="copy-of(//PRICE)"/>  
+            </xsl:fork>
+          </a>
+        </xsl:conditional-content>  
+      </out>
+    </xsl:stream>
+  </xsl:template> 
+  
+  <!-- Test of xsl:conditional-content with xsl:fork -->
+
+  <xsl:template name="s-011" use-when="$RUN">
+    <xsl:stream href="../docs/books.xml">
+      <out>
+        <xsl:conditional-content>
+          <a>
+            <xsl:fork>
+              <xsl:sequence select="copy-of(//TITTLE)"/>
+              <xsl:sequence select="copy-of(//PRICLE)"/>  
+            </xsl:fork>
+          </a>
+        </xsl:conditional-content>  
+      </out>
+    </xsl:stream>
+  </xsl:template>
+  
+  <!-- Test of xsl:conditional-content with document nodes -->
+  
+  <xsl:template name="s-012" use-when="$RUN">
+    <xsl:stream href="../docs/books.xml">
+      <out>
+        <xsl:variable name="t" as="document-node()?">          
+          <xsl:conditional-content>
+            <xsl:document>
+              <xsl:copy-of select="//TITLE[@flamingo]"/>
+            </xsl:document>
+          </xsl:conditional-content>
+        </xsl:variable>
+        <in value="{empty($t)}"/>     
+      </out>
+    </xsl:stream>
+  </xsl:template> 
+ 
+
+
+
+
+</xsl:stylesheet>