Add streaming tests for xsl:on-empty
authorMichael Kay <mike@saxonica.com>
Tue, 07 Jul 2015 12:44:16 +0100
changeset 1008 6bbfa81e7cec
parent 1007 22208a321c2a
child 1009 f8dabd091111
Add streaming tests for xsl:on-empty
catalog.xml
tests/strm/si-on-empty/_si-on-empty-test-set.xml
tests/strm/si-on-empty/si-on-empty-A.xsl
--- a/catalog.xml	Mon Jul 06 11:44:43 2015 +0100
+++ b/catalog.xml	Tue Jul 07 12:44:16 2015 +0100
@@ -223,6 +223,7 @@
       <test-set name="si-map" file="tests/strm/si-map/_si-map-test-set.xml"/>
       <test-set name="si-merge" file="tests/strm/si-merge/_si-merge-test-set.xml"/>
       <test-set name="si-next-match" file="tests/strm/si-next-match/_si-next-match-test-set.xml"/>
+      <test-set name="si-on-empty" file="tests/strm/si-on-empty/_si-on-empty-test-set.xml"/>
       <test-set name="si-result-document" file="tests/strm/si-result-document/_si-result-document-test-set.xml"/>
       <test-set name="si-try" file="tests/strm/si-try/_si-try-test-set.xml"/>
       <test-set name="si-value-of" file="tests/strm/si-value-of/_si-value-of-test-set.xml"/>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/strm/si-on-empty/_si-on-empty-test-set.xml	Tue Jul 07 12:44:16 2015 +0100
@@ -0,0 +1,413 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<test-set xmlns="http://www.w3.org/2012/10/xslt-test-catalog" xmlns:xs="http://www.w3.org/2001/XMLSchema" name="si-on-empty">
+   <description>Tests xsl:stream instruction introduced in XSLT 3.0 with xsl:on-empty.</description>
+   
+   <environment name="si-on-empty-A">
+     <stylesheet file="si-on-empty-A.xsl"/>
+   </environment>
+   
+   <dependencies>
+      <spec value="XSLT30+"/>
+      <feature value="streaming"/>
+   </dependencies>
+   
+   <test-case name="si-on-empty-001">
+      <description>xsl:element; value is consuming; xsl:on-empty</description>
+      <created by="Michael Kay" on="2015-07-02"/>
+      <environment ref="si-on-empty-A"/>
+      <test>
+         <initial-template name="s-001"/>
+      </test>
+      <result>
+         <assert>exists(/out/a)</assert>
+      </result>
+   </test-case>
+   
+   <test-case name="si-on-empty-002">
+      <description>Test of xsl:stream instruction with xsl:on-empty</description>
+      <created by="Michael Kay" on="2015-07-02"/>
+      <environment ref="si-on-empty-A"/>  
+      <test>
+         <initial-template name="s-002"/>
+      </test>
+      <result>
+         <assert-xml><![CDATA[<Results><first>one</first><second
+         /><CATEGORY CODE="P" DESC="Paperback"/><CATEGORY CODE="MMP" DESC="Mass-market Paperback"/><CATEGORY CODE="H" DESC="Hard Cover"
+         /><last>last</last></Results>]]></assert-xml>
+      </result>
+   </test-case>
+   
+   <test-case name="si-on-empty-003">
+      <description>Test of xsl:on-empty with atomic values, some 'empty'</description>
+      <created by="Michael Kay" on="2015-07-02"/>
+      <environment ref="si-on-empty-A"/>  
+      <test>
+         <initial-template name="s-003"/>
+      </test>
+      <result>
+         <assert>/out = "23  2011-01-01  0 "</assert>
+      </result>
+   </test-case>
+   
+   <test-case name="si-on-empty-004">
+      <description>Test of xsl:on-empty with xsl:if</description>
+      <created by="Michael Kay" on="2015-07-02"/>
+      <environment ref="si-on-empty-A"/>  
+      <test>
+         <initial-template name="s-004"/>
+      </test>
+      <result>
+         <assert>exists(/out/a)</assert>
+      </result>
+   </test-case>
+   
+   <test-case name="si-on-empty-005">
+      <description>Test of xsl:on-empty with xsl:if</description>
+      <created by="Michael Kay" on="2015-07-02"/>
+      <environment ref="si-on-empty-A"/>  
+      <test>
+         <initial-template name="s-005"/>
+      </test>
+      <result>
+         <assert>exists(/out/a/banana)</assert>
+      </result>
+   </test-case>
+   
+   <test-case name="si-on-empty-006">
+      <description>Test of xsl:on-empty with xsl:for-each</description>
+      <created by="Michael Kay" on="2015-07-02"/>
+      <environment ref="si-on-empty-A"/>  
+      <test>
+         <initial-template name="s-006"/>
+      </test>
+      <result>
+         <assert>exists(/out/ul/li)</assert>
+      </result>
+   </test-case>
+   
+   <test-case name="si-on-empty-007">
+      <description>Test of xsl:on-empty with xsl:for-each</description>
+      <created by="Michael Kay" on="2015-07-02"/>
+      <environment ref="si-on-empty-A"/>  
+      <test>
+         <initial-template name="s-007"/>
+      </test>
+      <result>
+         <assert>exists(/out/ul)</assert>
+      </result>
+   </test-case>
+   
+   <test-case name="si-on-empty-008">
+      <description>Test of xsl:on-empty with comment nodes</description>
+      <created by="Michael Kay" on="2015-07-02"/>
+      <environment ref="si-on-empty-A"/>  
+      <test>
+         <initial-template name="s-008"/>
+      </test>
+      <result>
+         <assert>count(/out/in/comment()[.='3']) = 6</assert>
+      </result>
+   </test-case>
+   
+   <test-case name="si-on-empty-009">
+      <description>Test of xsl:on-empty with text nodes</description>
+      <created by="Michael Kay" on="2015-07-02"/>
+      <environment ref="si-on-empty-A"/>  
+      <test>
+         <initial-template name="s-009"/>
+      </test>
+      <result>
+         <assert>count(/out/in[.='3']) = 6</assert>
+      </result>
+   </test-case>
+   
+   <test-case name="si-on-empty-010">
+      <description>Test of xsl:on-empty with xsl:fork</description>
+      <created by="Michael Kay" on="2015-07-02"/>
+      <environment ref="si-on-empty-A"/>  
+      <test>
+         <initial-template name="s-010"/>
+      </test>
+      <result>
+         <assert-xml><![CDATA[<out><a><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></a></out>]]></assert-xml>
+      </result>
+   </test-case>
+   
+   <test-case name="si-on-empty-011">
+      <description>Test of xsl:on-empty with xsl:fork</description>
+      <created by="Michael Kay" on="2015-07-02"/>
+      <environment ref="si-on-empty-A"/>  
+      <test>
+         <initial-template name="s-011"/>
+      </test>
+      <result>
+         <assert-xml><![CDATA[<out><a/></out>]]></assert-xml>
+      </result>
+   </test-case>
+   
+   <test-case name="si-on-empty-012">
+      <description>Test of xsl:on-empty with document nodes</description>
+      <created by="Michael Kay" on="2015-07-02"/>
+      <environment ref="si-on-empty-A"/>  
+      <test>
+         <initial-template name="s-012"/>
+      </test>
+      <result>
+         <assert>/out/in/@value = 'false'</assert>
+      </result>
+   </test-case>
+   
+   
+   <test-case name="si-on-empty-021">
+      <description>Test of xsl:on-empty with xsl:element (empty)</description>
+      <created by="Michael Kay" on="2015-07-02"/>
+      <environment ref="si-on-empty-A"/>  
+      <test>
+         <initial-template name="s-021"/>
+      </test>
+      <result>
+         <assert>/out/a = 'There is no price data'</assert>
+      </result>
+   </test-case>
+   
+   <test-case name="si-on-empty-022">
+      <description>Test of xsl:on-empty with xsl:element (not empty)</description>
+      <created by="Michael Kay" on="2015-07-02"/>
+      <environment ref="si-on-empty-A"/>  
+      <test>
+         <initial-template name="s-022"/>
+      </test>
+      <result>
+         <assert-xml><![CDATA[<out><a><PRICE>4.95</PRICE><PRICE>6.58</PRICE><PRICE>4.95</PRICE
+         ><PRICE>4.95</PRICE><PRICE>16.47</PRICE><PRICE>16.47</PRICE></a></out>]]></assert-xml>
+      </result>
+   </test-case>
+   
+   <test-case name="si-on-empty-023">
+      <description>Test of xsl:on-empty with xsl:element (empty)</description>
+      <created by="Michael Kay" on="2015-07-02"/>
+      <environment ref="si-on-empty-A"/>  
+      <test>
+         <initial-template name="s-023"/>
+      </test>
+      <result>
+         <assert>/out/a = 'There is no price data'</assert>
+      </result>
+   </test-case>
+   
+   <test-case name="si-on-empty-024">
+      <description>Test of xsl:on-empty with xsl:element (not empty)</description>
+      <created by="Michael Kay" on="2015-07-02"/>
+      <environment ref="si-on-empty-A"/>  
+      <test>
+         <initial-template name="s-024"/>
+      </test>
+      <result>
+         <assert-xml><![CDATA[<out><a><PRICE>4.95</PRICE><PRICE>6.58</PRICE><PRICE>4.95</PRICE
+         ><PRICE>4.95</PRICE><PRICE>16.47</PRICE><PRICE>16.47</PRICE></a></out>]]></assert-xml>
+      </result>
+   </test-case>
+   
+   <test-case name="si-on-empty-025">
+      <description>Test of xsl:on-empty with multiple elements (some empty)</description>
+      <created by="Michael Kay" on="2015-07-02"/>
+      <environment ref="si-on-empty-A"/>  
+      <test>
+         <initial-template name="s-025"/>
+      </test>
+      <result>
+         <assert>/out = 'true'</assert>
+      </result>
+   </test-case>
+   
+   <test-case name="si-on-empty-026">
+      <description>Test of xsl:on-empty with multiple elements (some empty)</description>
+      <created by="Michael Kay" on="2015-07-02"/>
+      <environment ref="si-on-empty-A"/>  
+      <test>
+         <initial-template name="s-026"/>
+      </test>
+      <result>
+         <assert>/out = 'true'</assert>
+      </result>
+   </test-case>
+   
+   <test-case name="si-on-empty-027">
+      <description>Test of xsl:on-empty with multiple elements (all empty)</description>
+      <created by="Michael Kay" on="2015-07-02"/>
+      <environment ref="si-on-empty-A"/>  
+      <test>
+         <initial-template name="s-027"/>
+      </test>
+      <result>
+         <assert>/out = 'There is no price data'</assert>
+      </result>
+   </test-case>
+   
+   <test-case name="si-on-empty-028">
+      <description>Test of xsl:on-empty with atomic values</description>
+      <created by="Michael Kay" on="2015-07-02"/>
+      <environment ref="si-on-empty-A"/>  
+      <test>
+         <initial-template name="s-028"/>
+      </test>
+      <result>
+         <assert>/out = '20'</assert>
+      </result>
+   </test-case>
+   
+   <test-case name="si-on-empty-029">
+      <description>Test of xsl:on-empty with atomic values</description>
+      <created by="Michael Kay" on="2015-07-02"/>
+      <environment ref="si-on-empty-A"/>  
+      <test>
+         <initial-template name="s-029"/>
+      </test>
+      <result>
+         <assert>/out = '4.95 6.58 4.95 4.95 16.47 16.47'</assert>
+      </result>
+   </test-case>
+   
+   <test-case name="si-on-empty-030">
+      <description>Test of xsl:on-empty with xsl:variable</description>
+      <created by="Michael Kay" on="2015-07-02"/>
+      <environment ref="si-on-empty-A"/>  
+      <test>
+         <initial-template name="s-030"/>
+      </test>
+      <result>
+         <assert>/out = "There is no price data within BOOKLIST"</assert>
+      </result>
+   </test-case>
+   
+   <test-case name="si-on-empty-031">
+      <description>Test of xsl:on-empty with xsl:variable</description>
+      <created by="Michael Kay" on="2015-07-02"/>
+      <environment ref="si-on-empty-A"/>  
+      <test>
+         <initial-template name="s-031"/>
+      </test>
+      <result>
+         <assert>/out = 'There is no price data within BOOKLIST'</assert>
+      </result>
+   </test-case>
+   
+   <test-case name="si-on-empty-032">
+      <description>Test of xsl:on-empty with xsl:if</description>
+      <created by="Michael Kay" on="2015-07-02"/>
+      <environment ref="si-on-empty-A"/>  
+      <test>
+         <initial-template name="s-032"/>
+      </test>
+      <result>
+         <assert>/out = 'Howdy!'</assert>
+      </result>
+   </test-case>
+   
+   <test-case name="si-on-empty-033">
+      <description>Test of xsl:on-empty with xsl:if</description>
+      <created by="Michael Kay" on="2015-07-02"/>
+      <environment ref="si-on-empty-A"/>  
+      <test>
+         <initial-template name="s-033"/>
+      </test>
+      <result>
+         <assert-xml><![CDATA[<out><banana x="78"/></out>]]></assert-xml>
+      </result>
+   </test-case>
+   
+   <test-case name="si-on-empty-034">
+      <description>Test of xsl:on-empty with xsl:for-each and xsl:conditional-content</description>
+      <created by="Michael Kay" on="2015-07-02"/>
+      <environment ref="si-on-empty-A"/>  
+      <test>
+         <initial-template name="s-034"/>
+      </test>
+      <result>
+         <assert>/out = 'There has been no gossip.'</assert>
+      </result>
+   </test-case>
+   
+   <test-case name="si-on-empty-035">
+      <description>Test of xsl:on-empty with xsl:for-each and xsl:conditional-content</description>
+      <created by="Michael Kay" on="2015-07-02"/>
+      <environment ref="si-on-empty-A"/>  
+      <test>
+         <initial-template name="s-035"/>
+      </test>
+      <result>
+         <assert>/out = 'There will be no gossip.'</assert>
+      </result>
+   </test-case>
+   
+   <test-case name="si-on-empty-036">
+      <description>Test of xsl:on-empty with xsl:for-each and xsl:conditional-content</description>
+      <created by="Michael Kay" on="2015-07-02"/>
+      <environment ref="si-on-empty-A"/>  
+      <test>
+         <initial-template name="s-036"/>
+      </test>
+      <result>
+         <assert>/out = "There will be no gossip.There has been no gossip."</assert>
+      </result>
+   </test-case>
+   
+   <test-case name="si-on-empty-037">
+      <description>Test of xsl:on-empty with xsl:fork</description>
+      <created by="Michael Kay" on="2015-07-02"/>
+      <environment ref="si-on-empty-A"/>  
+      <test>
+         <initial-template name="s-037"/>
+      </test>
+      <result>
+         <assert-xml><![CDATA[<out><a><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></a></out>]]></assert-xml>
+      </result>
+   </test-case>
+   
+   <test-case name="si-on-empty-038">
+      <description>Test of xsl:on-empty with xsl:fork</description>
+      <created by="Michael Kay" on="2015-07-02"/>
+      <environment ref="si-on-empty-A"/>  
+      <test>
+         <initial-template name="s-038"/>
+      </test>
+      <result>
+         <assert>/out/a = 'The forks were empty.'</assert>
+      </result>
+   </test-case>
+   
+   <test-case name="si-on-empty-039">
+      <description>Test of consuming xsl:on-empty (executed)</description>
+      <created by="Michael Kay" on="2015-07-02"/>
+      <environment ref="si-on-empty-A"/>  
+      <test>
+         <initial-template name="s-039"/>
+      </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></out>]]></assert-xml>
+      </result>
+   </test-case>
+   
+   <test-case name="si-on-empty-040">
+      <description>Test of consuming xsl:on-empty (not executed)</description>
+      <created by="Michael Kay" on="2015-07-02"/>
+      <environment ref="si-on-empty-A"/>  
+      <test>
+         <initial-template name="s-040"/>
+      </test>
+      <result>
+         <assert-xml><![CDATA[<out><content/></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/si-on-empty/si-on-empty-A.xsl	Tue Jul 07 12:44:16 2015 +0100
@@ -0,0 +1,507 @@
+<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="*"/>
+
+ 
+  <!-- Note, the first few tests are mechanically copied from xsl:conditional-content
+       tests. They don't do anything meaningful, but are retained to ensure the code
+       paths work. -->
+        
+ 
+  
+  <!-- Test of xsl:on-empty with xsl:element (not empty) -->
+
+  <xsl:template name="s-001" use-when="$RUN">
+    <xsl:stream href="../docs/books.xml">
+      <out>
+        <xsl:on-empty>
+          <xsl:element name="a">
+            <xsl:sequence select="./BOOKLIST/BOOKS/ITEM/PRICEDATA"/>
+          </xsl:element>
+        </xsl:on-empty>  
+      </out>
+    </xsl:stream>
+  </xsl:template>
+  
+  <!-- Test of xsl:on-empty with multiple elements, some empty -->
+  
+  <xsl:template name="s-002" use-when="$RUN">
+       <xsl:stream href="../docs/books.xml">
+           <Results>
+               <xsl:on-empty>
+                 <first>one</first>
+                 <second/>
+                 <xsl:copy-of select="BOOKLIST/CATEGORIES/*" />
+                 <last>last</last>
+               </xsl:on-empty>
+           </Results>
+       </xsl:stream>
+   </xsl:template> 
+   
+   <!-- Test of xsl:on-empty with atomic values, some empty -->
+  
+  <xsl:template name="s-003" use-when="$RUN">
+       <xsl:stream href="../docs/books.xml">
+           <out>
+               <xsl:on-empty>
+                 <xsl:sequence select="23, '', xs:date('2011-01-01'), xs:untypedAtomic(''), 0, /JUNK, xs:base64Binary('')"/>
+               </xsl:on-empty>
+           </out>
+       </xsl:stream>
+   </xsl:template>
+   
+   <!-- Test of xsl:on-empty with xsl:if -->
+
+  <xsl:template name="s-004" use-when="$RUN">
+    <xsl:stream href="../docs/books.xml">
+      <out>
+        <xsl:on-empty>
+          <a>
+            <xsl:if test="current-date() lt xs:date('1900-01-01')">
+               <banana x="{count(//*)}"/>
+            </xsl:if>
+          </a>
+        </xsl:on-empty>  
+      </out>
+    </xsl:stream>
+  </xsl:template> 
+  
+  <!-- Test of xsl:on-empty with xsl:if -->
+
+  <xsl:template name="s-005" use-when="$RUN">
+    <xsl:stream href="../docs/books.xml">
+      <out>
+        <xsl:on-empty>
+          <a>
+            <xsl:if test="current-date() gt xs:date('1900-01-01')">
+               <banana x="{count(//*)}"/>
+            </xsl:if>
+          </a>
+        </xsl:on-empty>  
+      </out>
+    </xsl:stream>
+  </xsl:template> 
+  
+  <!-- Test of xsl:on-empty with xsl:for-each -->
+
+  <xsl:template name="s-006" use-when="$RUN">
+    <xsl:stream href="../docs/books.xml">
+      <out>
+        <xsl:on-empty>
+          <ul>
+            <xsl:for-each select="outermost(//ITEM)">
+              <li><xsl:value-of select="TITLE"/></li>
+            </xsl:for-each>  
+          </ul>
+        </xsl:on-empty>  
+      </out>
+    </xsl:stream>
+  </xsl:template> 
+  
+  <!-- Test of xsl:on-empty with xsl:for-each -->
+
+  <xsl:template name="s-007" use-when="$RUN">
+    <xsl:stream href="../docs/books.xml">
+      <out>
+        <xsl:on-empty>
+          <ul>
+            <xsl:for-each select="outermost(//MAGAZINE)">
+              <li><xsl:value-of select="TITLE"/></li>
+            </xsl:for-each>  
+          </ul>
+        </xsl:on-empty>  
+      </out>
+    </xsl:stream>
+  </xsl:template> 
+  
+  <!-- Test of xsl:on-empty 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:on-empty>
+              <xsl:comment select="TITLE[parent::BOOK]"/>
+            </xsl:on-empty>
+            <xsl:on-empty>
+              <xsl:comment select="count(ancestor::node())"/>
+            </xsl:on-empty> 
+          </in>  
+         </xsl:for-each>  
+      </out>
+    </xsl:stream>
+  </xsl:template> 
+  
+  <!-- Test of xsl:on-empty 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:on-empty>
+              <xsl:value-of select="TITLE[parent::BOOK]"/>
+            </xsl:on-empty>
+            <xsl:on-empty>
+              <xsl:value-of select="count(ancestor::node())"/>
+            </xsl:on-empty> 
+          </in>  
+         </xsl:for-each>  
+      </out>
+    </xsl:stream>
+  </xsl:template> 
+  
+  <!-- Test of xsl:on-empty with xsl:fork -->
+
+  <xsl:template name="s-010" use-when="$RUN">
+    <xsl:stream href="../docs/books.xml">
+      <out>
+        <xsl:on-empty>
+          <a>
+            <xsl:fork>
+              <xsl:sequence select="copy-of(//TITLE)"/>
+              <xsl:sequence select="copy-of(//PRICE)"/>  
+            </xsl:fork>
+          </a>
+        </xsl:on-empty>  
+      </out>
+    </xsl:stream>
+  </xsl:template> 
+  
+  <!-- Test of xsl:on-empty with xsl:fork -->
+
+  <xsl:template name="s-011" use-when="$RUN">
+    <xsl:stream href="../docs/books.xml">
+      <out>
+        <xsl:on-empty>
+          <a>
+            <xsl:fork>
+              <xsl:sequence select="copy-of(//TITTLE)"/>
+              <xsl:sequence select="copy-of(//PRICLE)"/>  
+            </xsl:fork>
+          </a>
+        </xsl:on-empty>  
+      </out>
+    </xsl:stream>
+  </xsl:template>
+  
+  <!-- Test of xsl:on-empty 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:on-empty>
+            <xsl:document>
+              <xsl:copy-of select="//TITLE[@flamingo]"/>
+            </xsl:document>
+          </xsl:on-empty>
+        </xsl:variable>
+        <in value="{empty($t)}"/>     
+      </out>
+    </xsl:stream>
+  </xsl:template> 
+ 
+  <!-- Test of xsl:on-empty with xsl:element (empty) -->
+  
+  <xsl:template name="s-021" use-when="$RUN">
+    <xsl:stream href="../docs/books.xml">
+      <out>
+        <xsl:element name="a">
+          <xsl:sequence select="./BOOKLIST/BOOKS/ITEM/PRICEDATA"/>
+          <xsl:on-empty>There is no price data</xsl:on-empty>
+        </xsl:element>         
+      </out>
+    </xsl:stream>
+  </xsl:template>
+  
+  <!-- Test of xsl:on-empty with xsl:element (not empty) -->
+  
+  <xsl:template name="s-022" use-when="$RUN">
+    <xsl:stream href="../docs/books.xml">
+      <out>
+        <xsl:element name="a">
+          <xsl:sequence select="./BOOKLIST/BOOKS/ITEM/PRICE"/>
+          <xsl:on-empty>There is no price data</xsl:on-empty>
+        </xsl:element>         
+      </out>
+    </xsl:stream>
+  </xsl:template>
+  
+  <!-- Test of xsl:on-empty with xsl:element (empty) -->
+  
+  <xsl:template name="s-023" use-when="$RUN">
+    <xsl:stream href="../docs/books.xml">
+      <out>
+        <xsl:element name="a">
+          <xsl:on-empty>There is no price data</xsl:on-empty>
+          <xsl:sequence select="./BOOKLIST/BOOKS/ITEM/PRICEDATA"/>         
+        </xsl:element>         
+      </out>
+    </xsl:stream>
+  </xsl:template>
+  
+  <!-- Test of xsl:on-empty with xsl:element (not empty) -->
+  
+  <xsl:template name="s-024" use-when="$RUN">
+    <xsl:stream href="../docs/books.xml">
+      <out>
+        <xsl:element name="a">
+          <xsl:on-empty>There is no price data</xsl:on-empty>
+          <xsl:sequence select="./BOOKLIST/BOOKS/ITEM/PRICE"/>         
+        </xsl:element>         
+      </out>
+    </xsl:stream>
+  </xsl:template>
+  
+  <!-- Test of xsl:on-empty with multiple elements, some empty -->
+  
+  <xsl:template name="s-025" use-when="$RUN">
+    <xsl:stream href="../docs/books.xml">
+      <out>
+        <xsl:sequence select="./BOOKLIST/BOOKS/ITEM/PRICEDATA"/>  
+        <xsl:on-empty>There is no price data</xsl:on-empty>
+        <xsl:sequence select="ends-with(document-uri(), 'books.xml')"/>    
+      </out>
+    </xsl:stream>
+  </xsl:template> 
+  
+  <!-- Test of xsl:on-empty with multiple elements, some empty -->
+  
+  <xsl:template name="s-026" use-when="$RUN">
+    <xsl:stream href="../docs/books.xml">
+      <out>
+        <xsl:sequence select="ends-with(document-uri(), 'books.xml')"/>  
+        <xsl:on-empty>There is no price data</xsl:on-empty>
+        <xsl:sequence select="./BOOKLIST/BOOKS/ITEM/PRICEDATA"/>    
+      </out>
+    </xsl:stream>
+  </xsl:template> 
+  
+  <!-- Test of xsl:on-empty with multiple elements, all empty -->
+  
+  <xsl:template name="s-027" use-when="$RUN">
+    <xsl:stream href="../docs/books.xml">
+      <out>
+        <xsl:for-each select="BOOKLIST">
+          <xsl:sequence select="data(@dummy)"/>  
+          <xsl:on-empty>There is no price data</xsl:on-empty>
+          <xsl:sequence select="BOOKS/ITEM/PRICEDATA"/> 
+        </xsl:for-each>
+      </out>
+    </xsl:stream>
+  </xsl:template> 
+  
+  <!-- Test of xsl:on-empty with atomic values, some empty -->
+  
+  <xsl:template name="s-028" use-when="$RUN">
+    <xsl:stream href="../docs/books.xml">
+      <out>
+        <xsl:sequence select="(1 to 20)[. ge 20]"/>  
+        <xsl:on-empty>There is no price data</xsl:on-empty>
+        <xsl:sequence select="./BOOKLIST/BOOKS/ITEM/PRICEDATA/data()"/> 
+      </out>
+    </xsl:stream>
+  </xsl:template>
+  
+  <!-- Test of xsl:on-empty with atomic values, some empty -->
+  
+  <xsl:template name="s-029" use-when="$RUN">
+    <xsl:stream href="../docs/books.xml">
+      <out>
+        <xsl:sequence select="(1 to 20)[. ge 40]"/>  
+        <xsl:on-empty>There is no price data</xsl:on-empty>
+        <xsl:sequence select="./BOOKLIST/BOOKS/ITEM/PRICE/data()"/> 
+      </out>
+    </xsl:stream>
+  </xsl:template>
+  
+  <!-- Test of xsl:on-empty with xsl:variable -->
+  
+  <xsl:template name="s-030" use-when="$RUN">
+    <xsl:stream href="../docs/books.xml">
+      <xsl:for-each select="BOOKLIST">
+        <out>
+          <xsl:variable name="x" select="name()"/>
+          <xsl:on-empty>There is no price data within <xsl:value-of select="$x"/></xsl:on-empty> 
+        </out>
+      </xsl:for-each>
+    </xsl:stream>
+  </xsl:template>
+  
+  <!-- Test of xsl:on-empty with xsl:variable -->
+  
+  <xsl:template name="s-031" use-when="$RUN">
+    <xsl:stream href="../docs/books.xml">
+      <xsl:for-each select="BOOKLIST">
+        <out>
+          <xsl:sequence select="BOOKS/ITEM/PRICEDATA"/>
+          <xsl:variable name="x" select="name()"/>
+          <xsl:on-empty>There is no price data within <xsl:value-of select="$x"/></xsl:on-empty>
+        </out>
+      </xsl:for-each>
+    </xsl:stream>
+  </xsl:template>
+  
+  <!-- Test of xsl:on-empty with xsl:if -->
+  
+  <xsl:template name="s-032" use-when="$RUN">
+    <xsl:stream href="../docs/books.xml">
+      <out>
+          <xsl:if test="current-date() lt xs:date('1900-01-01')">
+            <banana x="{count(//*)}"/>
+          </xsl:if>
+          <xsl:on-empty>Howdy!</xsl:on-empty>  
+      </out>
+    </xsl:stream>
+  </xsl:template> 
+  
+  <!-- Test of xsl:on-empty with xsl:if -->
+  
+  <xsl:template name="s-033" use-when="$RUN">
+    <xsl:stream href="../docs/books.xml">
+      <out>
+          <xsl:if test="current-date() gt xs:date('1900-01-01')">
+            <banana x="{count(//*)}"/>
+          </xsl:if>
+          <xsl:on-empty>Howdy!</xsl:on-empty>       
+      </out>
+    </xsl:stream>
+  </xsl:template> 
+  
+  <!-- Test of xsl:on-empty with xsl:for-each and xsl:conditional-content -->
+  
+  <xsl:template name="s-034" use-when="$RUN">
+    <xsl:stream href="../docs/books.xml">
+      <out>
+        <xsl:conditional-content>
+          <ul>
+            <xsl:for-each select="outermost(//ITEM)">
+              <xsl:conditional-content>
+                <li><xsl:value-of select="TITTLE-TATTLE"/></li>
+              </xsl:conditional-content>
+            </xsl:for-each>  
+          </ul>
+        </xsl:conditional-content>
+        <xsl:on-empty>There has been no gossip.</xsl:on-empty>
+      </out>
+    </xsl:stream>
+  </xsl:template> 
+  
+  <!-- Test of xsl:on-empty with xsl:for-each and xsl:conditional-content -->
+  
+  <xsl:template name="s-035" use-when="$RUN">
+    <xsl:stream href="../docs/books.xml">
+      <out>
+        <xsl:on-empty>There will be no gossip.</xsl:on-empty>
+        <xsl:conditional-content>
+          <ul>
+            <xsl:for-each select="outermost(//ITEM)">
+              <xsl:conditional-content>
+                <li><xsl:value-of select="TITTLE-TATTLE"/></li>
+              </xsl:conditional-content>
+            </xsl:for-each>  
+          </ul>
+        </xsl:conditional-content>
+      </out>
+    </xsl:stream>
+  </xsl:template> 
+  
+  <!-- Test of xsl:on-empty (appearing twice) with xsl:for-each and xsl:conditional-content -->
+  
+  <xsl:template name="s-036" use-when="$RUN">
+    <xsl:stream href="../docs/books.xml">
+      <out>
+        <xsl:on-empty>There will be no gossip.</xsl:on-empty>
+        <xsl:conditional-content>
+          <ul>
+            <xsl:for-each select="outermost(//ITEM)">
+              <xsl:conditional-content>
+                <li><xsl:value-of select="TITTLE-TATTLE"/></li>
+              </xsl:conditional-content>
+            </xsl:for-each>  
+          </ul>
+        </xsl:conditional-content>
+        <xsl:on-empty>There has been no gossip.</xsl:on-empty>
+      </out>
+    </xsl:stream>
+  </xsl:template> 
+  
+  
+  <!-- Test of xsl:on-empty with xsl:fork -->
+  
+  <xsl:template name="s-037" use-when="$RUN">
+    <xsl:stream href="../docs/books.xml">
+      <out>
+        <a>
+          <xsl:fork>
+            <xsl:sequence select="copy-of(//TITLE)"/>
+            <xsl:sequence select="copy-of(//PRICE)"/>  
+          </xsl:fork>
+          <xsl:on-empty>The forks were empty.</xsl:on-empty>
+        </a>        
+      </out>
+    </xsl:stream>
+  </xsl:template> 
+  
+  <!-- Test of xsl:on-empty with xsl:fork -->
+  
+  <xsl:template name="s-038" use-when="$RUN">
+    <xsl:stream href="../docs/books.xml">
+      <out>
+        <a>
+          <xsl:fork>
+            <xsl:sequence select="copy-of(//TITTLE)"/>
+            <xsl:sequence select="copy-of(//PRICLE)"/>  
+          </xsl:fork>
+          <xsl:on-empty>The forks were empty.</xsl:on-empty>
+        </a>        
+      </out>
+    </xsl:stream>
+  </xsl:template> 
+  
+  <!-- Test of consuming xsl:on-empty (executed) -->
+  
+  <xsl:template name="s-039" use-when="$RUN">
+    <xsl:stream href="../docs/books.xml">
+      <out>
+        <xsl:if test="current-date() lt xs:date('1900-01-01')">
+          <content/>
+        </xsl:if>
+        <xsl:on-empty>
+          <xsl:for-each select="/BOOKLIST/BOOKS/ITEM">
+            <xsl:copy-of select="TITLE"/>
+          </xsl:for-each>
+        </xsl:on-empty>
+      </out>
+    </xsl:stream>
+  </xsl:template> 
+  
+  <!-- Test of consuming xsl:on-empty (not executed) -->
+  
+  <xsl:template name="s-040" use-when="$RUN">
+    <xsl:stream href="../docs/books.xml">
+      <out>
+        <xsl:if test="current-date() gt xs:date('1900-01-01')">
+          <content/>
+        </xsl:if>
+        <xsl:on-empty>
+          <xsl:for-each select="/BOOKLIST/BOOKS/ITEM">
+            <xsl:copy-of select="TITLE"/>
+          </xsl:for-each>
+        </xsl:on-empty>
+      </out>
+    </xsl:stream>
+  </xsl:template> 
+  
+  
+
+
+
+
+</xsl:stylesheet>