Changes to on-empty and on-non-empty for bug 28888
authorMichael Kay <mike@saxonica.com>
Sun, 16 Aug 2015 23:56:35 +0100
changeset 1042 62fbcfcc2c5d
parent 1041 96cb3048ae26
child 1043 b1148259e9b4
Changes to on-empty and on-non-empty for bug 28888
tests/insn/on-empty/_on-empty-test-set.xml
tests/insn/on-empty/on-empty-006.xsl
tests/insn/on-empty/on-empty-007.xsl
tests/insn/on-empty/on-empty-011.xsl
tests/insn/on-empty/on-empty-012.xsl
tests/insn/on-non-empty/_on-non-empty-test-set.xml
tests/insn/on-non-empty/on-non-empty-011.xsl
tests/insn/on-non-empty/on-non-empty-012.xsl
tests/insn/on-non-empty/on-non-empty-013.xsl
tests/insn/on-non-empty/on-non-empty-014.xsl
tests/strm/si-on-empty/_si-on-empty-test-set.xml
tests/strm/si-on-empty/si-on-empty-A.xsl
tests/strm/si-on-non-empty/_si-on-non-empty-test-set.xml
tests/strm/si-on-non-empty/si-on-non-empty-A.xsl
--- a/tests/insn/on-empty/_on-empty-test-set.xml	Fri Aug 14 10:00:23 2015 +0100
+++ b/tests/insn/on-empty/_on-empty-test-set.xml	Sun Aug 16 23:56:35 2015 +0100
@@ -50,8 +50,9 @@
    </test-case>
 
    <test-case name="on-empty-003">
-      <description>Simple use of xsl:on-empty with other instructions yielding empty</description>
+      <description>Simple use of xsl:on-empty before other instructions yielding empty</description>
       <created by="Michael Kay" on="2014-12-22"/>
+      <modified by="Michael Kay" on="2015-08-16" change="bug 28888 makes this an error"/>
       <environment ref="on-empty-A"/>
       <dependencies>
          <spec value="XSLT30+"/>
@@ -60,13 +61,14 @@
          <stylesheet file="on-empty-003.xsl"/>
       </test>
       <result>
-         <assert-xml><![CDATA[<out>23</out>]]></assert-xml>
+         <error code="XTSE0010"/>
       </result>
    </test-case>
 
    <test-case name="on-empty-004">
       <description>Simple use of xsl:on-empty with other instructions yielding non-empty</description>
       <created by="Michael Kay" on="2014-12-22"/>
+      <modified by="Michael Kay" on="2015-08-16" change="bug 28888 makes this an error"/>
       <environment ref="on-empty-A"/>
       <dependencies>
          <spec value="XSLT30+"/>
@@ -75,7 +77,7 @@
          <stylesheet file="on-empty-004.xsl"/>
       </test>
       <result>
-         <assert-xml><![CDATA[<out><doc><item>a</item><item>b</item><item>c</item></doc></out>]]></assert-xml>
+         <error code="XTSE0010"/>
       </result>
    </test-case>
 
@@ -95,8 +97,9 @@
    </test-case>
    
    <test-case name="on-empty-006">
-      <description>Multiple xsl:on-empty instructions yielding empty</description>
+      <description>xsl:on-empty at root level</description>
       <created by="Michael Kay" on="2014-12-22"/>
+      <modified by="Michael Kay" on="2015-08-16" change="modified so it's not an error under bug 28888"/>
       <environment ref="on-empty-A"/>
       <dependencies>
          <spec value="XSLT30+"/>
@@ -110,10 +113,8 @@
    </test-case>
    
    <test-case name="on-empty-007">
-      <description>Multiple xsl:on-empty instructions with local variables
-         (Note, MHK 2014-12-22, Saxon can't handle this yet)
-      </description>
-      <created by="Michael Kay" on="2014-12-22"/>
+      <description>xsl:on-empty followed by significant text nodes</description>
+      <created by="Michael Kay" on="2015-08-16"/>
       <environment ref="on-empty-A"/>
       <dependencies>
          <spec value="XSLT30+"/>
@@ -122,7 +123,7 @@
          <stylesheet file="on-empty-007.xsl"/>
       </test>
       <result>
-         <assert-xml><![CDATA[<out>21 23</out>]]></assert-xml>
+         <error code="XTSE0010"/>
       </result>
    </test-case>
    
@@ -170,6 +171,36 @@
          <assert-xml><![CDATA[<out>apple apple apple</out>]]></assert-xml>
       </result>
    </test-case>
+   
+   <test-case name="on-empty-011">
+      <description>Zero length text nodes count as empty (bug 28888)</description>
+      <created by="Michael Kay" on="2015-08-16"/>
+      <environment ref="on-empty-A"/>
+      <dependencies>
+         <spec value="XSLT30+"/>
+      </dependencies>
+      <test>
+         <stylesheet file="on-empty-011.xsl"/>
+      </test>
+      <result>
+         <assert-xml><![CDATA[<out>apple</out>]]></assert-xml>
+      </result>
+   </test-case>
+   
+   <test-case name="on-empty-012">
+      <description>Empty document nodes count as empty (bug 28888)</description>
+      <created by="Michael Kay" on="2015-08-16"/>
+      <environment ref="on-empty-A"/>
+      <dependencies>
+         <spec value="XSLT30+"/>
+      </dependencies>
+      <test>
+         <stylesheet file="on-empty-012.xsl"/>
+      </test>
+      <result>
+         <assert-xml><![CDATA[<out>apple</out>]]></assert-xml>
+      </result>
+   </test-case>
 
 
 </test-set>
--- a/tests/insn/on-empty/on-empty-006.xsl	Fri Aug 14 10:00:23 2015 +0100
+++ b/tests/insn/on-empty/on-empty-006.xsl	Sun Aug 16 23:56:35 2015 +0100
@@ -2,10 +2,9 @@
 
 <xsl:template match="/">
   <out>
-    <xsl:on-empty select="21"/>
     <xsl:copy-of select="/comment()"/>   
-    <xsl:on-empty select="23"/>
-    <xsl:copy-of select="/processing-instruction()"/> 
+    <xsl:copy-of select="/processing-instruction()"/>
+    <xsl:on-empty select="21, 23"/> 
   </out>
 </xsl:template>
 
--- a/tests/insn/on-empty/on-empty-007.xsl	Fri Aug 14 10:00:23 2015 +0100
+++ b/tests/insn/on-empty/on-empty-007.xsl	Sun Aug 16 23:56:35 2015 +0100
@@ -4,12 +4,9 @@
 
 <xsl:template match="/">
   <out>
-    <xsl:variable name="x" select="21 + $z"/>
-    <xsl:on-empty select="$x"/>
-    <xsl:copy-of select="/comment()"/>
-    <xsl:variable name="x" select="23 + $z"/>    
-    <xsl:on-empty select="$x"/>
-    <xsl:copy-of select="/processing-instruction()"/> 
+    <a/>
+    <xsl:on-empty select="23"/>
+    49
   </out>
 </xsl:template>
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/insn/on-empty/on-empty-011.xsl	Sun Aug 16 23:56:35 2015 +0100
@@ -0,0 +1,10 @@
+<xsl:stylesheet version="3.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+
+<xsl:template match="/">
+  <out>   
+      <xsl:value-of select="banana"/>
+      <xsl:on-empty select="'apple'"/> 
+  </out>
+</xsl:template>
+
+</xsl:stylesheet>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/insn/on-empty/on-empty-012.xsl	Sun Aug 16 23:56:35 2015 +0100
@@ -0,0 +1,14 @@
+<xsl:stylesheet version="3.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+
+      <xsl:param name="banana">
+        <xsl:copy-of select="/banana"/>
+      </xsl:param>
+
+<xsl:template match="/">
+  <out>   
+      <xsl:sequence select="$banana"/>
+      <xsl:on-empty select="'apple'"/> 
+  </out>
+</xsl:template>
+
+</xsl:stylesheet>
--- a/tests/insn/on-non-empty/_on-non-empty-test-set.xml	Fri Aug 14 10:00:23 2015 +0100
+++ b/tests/insn/on-non-empty/_on-non-empty-test-set.xml	Sun Aug 16 23:56:35 2015 +0100
@@ -168,6 +168,66 @@
          <assert-xml><![CDATA[<out><item>a</item>apple<item>b</item>apple<item>c</item>apple</out>]]></assert-xml>
       </result>
    </test-case>
+   
+   <test-case name="on-non-empty-011">
+      <description>Zero-length text node is considered empty</description>
+      <created by="Michael Kay" on="2015-08-16"/>
+      <environment ref="on-non-empty-A"/>
+      <dependencies>
+         <spec value="XSLT30+"/>
+      </dependencies>
+      <test>
+         <stylesheet file="on-non-empty-011.xsl"/>
+      </test>
+      <result>
+         <assert-xml><![CDATA[<out/>]]></assert-xml>
+      </result>
+   </test-case>
+   
+   <test-case name="on-non-empty-012">
+      <description>Empty document node is considered empty</description>
+      <created by="Michael Kay" on="2015-08-16"/>
+      <environment ref="on-non-empty-A"/>
+      <dependencies>
+         <spec value="XSLT30+"/>
+      </dependencies>
+      <test>
+         <stylesheet file="on-non-empty-012.xsl"/>
+      </test>
+      <result>
+         <assert-xml><![CDATA[<out/>]]></assert-xml>
+      </result>
+   </test-case>
+   
+   <test-case name="on-non-empty-013">
+      <description>on-empty must come last</description>
+      <created by="Michael Kay" on="2015-08-16"/>
+      <environment ref="on-non-empty-A"/>
+      <dependencies>
+         <spec value="XSLT30+"/>
+      </dependencies>
+      <test>
+         <stylesheet file="on-non-empty-013.xsl"/>
+      </test>
+      <result>
+         <error code="XTSE0010"/>
+      </result>
+   </test-case>
+   
+   <test-case name="on-non-empty-014">
+      <description>on-empty and on-non-empty can coexist</description>
+      <created by="Michael Kay" on="2015-08-16"/>
+      <environment ref="on-non-empty-A"/>
+      <dependencies>
+         <spec value="XSLT30+"/>
+      </dependencies>
+      <test>
+         <stylesheet file="on-non-empty-014.xsl"/>
+      </test>
+      <result>
+         <assert-xml><![CDATA[<out>EMPTY</out>]]></assert-xml>
+      </result>
+   </test-case>
 
 
 </test-set>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/insn/on-non-empty/on-non-empty-011.xsl	Sun Aug 16 23:56:35 2015 +0100
@@ -0,0 +1,16 @@
+<xsl:stylesheet version="3.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+
+<xsl:param name="z"/>
+
+<xsl:template match="/">
+  <out>
+    <xsl:value-of select="$z"/>
+    <xsl:on-non-empty>
+      <xsl:sequence select="23"/>
+      <xsl:fallback>18.2</xsl:fallback>
+    </xsl:on-non-empty>  
+    <xsl:fallback>93.7</xsl:fallback>
+  </out>
+</xsl:template>
+
+</xsl:stylesheet>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/insn/on-non-empty/on-non-empty-012.xsl	Sun Aug 16 23:56:35 2015 +0100
@@ -0,0 +1,18 @@
+<xsl:stylesheet version="3.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+
+<xsl:param name="z">
+  <xsl:copy-of select="/unicorn"/>
+</xsl:param>  
+
+<xsl:template match="/">
+  <out>
+    <xsl:copy-of select="$z"/>
+    <xsl:on-non-empty>
+      <xsl:sequence select="23"/>
+      <xsl:fallback>18.2</xsl:fallback>
+    </xsl:on-non-empty>  
+    <xsl:fallback>93.7</xsl:fallback>
+  </out>
+</xsl:template>
+
+</xsl:stylesheet>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/insn/on-non-empty/on-non-empty-013.xsl	Sun Aug 16 23:56:35 2015 +0100
@@ -0,0 +1,15 @@
+<xsl:stylesheet version="3.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+
+<xsl:param name="z">
+  <xsl:copy-of select="/unicorn"/>
+</xsl:param>  
+
+<xsl:template match="/">
+  <out>
+    <xsl:copy-of select="$z"/>
+    <xsl:on-empty>EMPTY</xsl:on-empty>
+    <xsl:on-non-empty>NON-EMPTY</xsl:on-non-empty>
+  </out>
+</xsl:template>
+
+</xsl:stylesheet>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/insn/on-non-empty/on-non-empty-014.xsl	Sun Aug 16 23:56:35 2015 +0100
@@ -0,0 +1,15 @@
+<xsl:stylesheet version="3.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+
+<xsl:param name="z">
+  <xsl:copy-of select="/unicorn"/>
+</xsl:param>  
+
+<xsl:template match="/">
+  <out>
+    <xsl:copy-of select="$z"/>
+    <xsl:on-non-empty>NON-EMPTY</xsl:on-non-empty>
+    <xsl:on-empty>EMPTY</xsl:on-empty>    
+  </out>
+</xsl:template>
+
+</xsl:stylesheet>
--- a/tests/strm/si-on-empty/_si-on-empty-test-set.xml	Fri Aug 14 10:00:23 2015 +0100
+++ b/tests/strm/si-on-empty/_si-on-empty-test-set.xml	Sun Aug 16 23:56:35 2015 +0100
@@ -88,6 +88,7 @@
    <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"/>
+      <modified by="Michael Kay" on="2015-08-16" change="spec change, see bug 28888"/>
       <environment ref="si-on-empty-A"/>  
       <test>
          <initial-template name="s-007"/>
@@ -112,6 +113,7 @@
    <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"/>
+      <modified by="Michael Kay" on="2015-08-16" change="spec change, see bug 28888"/>
       <environment ref="si-on-empty-A"/>  
       <test>
          <initial-template name="s-009"/>
@@ -214,6 +216,7 @@
    <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"/>
+      <modified by="Michael Kay" on="2015-08-16" change="spec change, see bug 28888"/>    
       <environment ref="si-on-empty-A"/>  
       <test>
          <initial-template name="s-025"/>
@@ -226,6 +229,7 @@
    <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"/>
+      <modified by="Michael Kay" on="2015-08-16" change="spec change, see bug 28888"/>    
       <environment ref="si-on-empty-A"/>  
       <test>
          <initial-template name="s-026"/>
@@ -238,6 +242,7 @@
    <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"/>
+      <modified by="Michael Kay" on="2015-08-16" change="spec change, see bug 28888"/>    
       <environment ref="si-on-empty-A"/>  
       <test>
          <initial-template name="s-027"/>
@@ -250,6 +255,7 @@
    <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"/>
+      <modified by="Michael Kay" on="2015-08-16" change="spec change, see bug 28888"/>    
       <environment ref="si-on-empty-A"/>  
       <test>
          <initial-template name="s-028"/>
@@ -262,6 +268,7 @@
    <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"/>
+      <modified by="Michael Kay" on="2015-08-16" change="spec change, see bug 28888"/>    
       <environment ref="si-on-empty-A"/>  
       <test>
          <initial-template name="s-029"/>
@@ -331,30 +338,6 @@
       </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"/>
@@ -408,6 +391,42 @@
          <assert-xml><![CDATA[<out><content/></out>]]></assert-xml>
       </result>
    </test-case>
+   
+   <test-case name="si-on-empty-041">
+      <description>Zero-length text nodes are considered empty</description>
+      <created by="Michael Kay" on="2015-08-16"/>
+      <environment ref="si-on-empty-A"/>  
+      <test>
+         <initial-template name="s-041"/>
+      </test>
+      <result>
+         <assert-xml><![CDATA[<out>EMPTY</out>]]></assert-xml>
+      </result>
+   </test-case>
+   
+   <test-case name="si-on-empty-042">
+      <description>Childless document nodes are considered empty</description>
+      <created by="Michael Kay" on="2015-08-16"/>
+      <environment ref="si-on-empty-A"/>  
+      <test>
+         <initial-template name="s-042"/>
+      </test>
+      <result>
+         <assert-xml><![CDATA[<out>EMPTY</out>]]></assert-xml>
+      </result>
+   </test-case>
+   
+   <test-case name="si-on-empty-043">
+      <description>Document nodes containing whitespace text are not considered empty</description>
+      <created by="Michael Kay" on="2015-08-16"/>
+      <environment ref="si-on-empty-A"/>  
+      <test>
+         <initial-template name="s-043"/>
+      </test>
+      <result>
+         <assert-xml><![CDATA[<out>  </out>]]></assert-xml>
+      </result>
+   </test-case>
 
 
 </test-set>
\ No newline at end of file
--- a/tests/strm/si-on-empty/si-on-empty-A.xsl	Fri Aug 14 10:00:23 2015 +0100
+++ b/tests/strm/si-on-empty/si-on-empty-A.xsl	Sun Aug 16 23:56:35 2015 +0100
@@ -136,8 +136,6 @@
             <xsl:sequence select="$empty"/>
             <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>  
@@ -156,8 +154,6 @@
             <xsl:sequence select="$empty"/>
             <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>  
@@ -254,8 +250,8 @@
     <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:sequence select="./BOOKLIST/BOOKS/ITEM/PRICEDATA"/> 
+          <xsl:on-empty>There is no price data</xsl:on-empty>                  
         </xsl:element>         
       </out>
     </xsl:stream>
@@ -267,8 +263,8 @@
     <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:sequence select="./BOOKLIST/BOOKS/ITEM/PRICE"/>
+          <xsl:on-empty>There is no price data</xsl:on-empty>         
         </xsl:element>         
       </out>
     </xsl:stream>
@@ -280,8 +276,8 @@
     <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')[empty($empty)]"/>    
+        <xsl:sequence select="ends-with(document-uri(), 'books.xml')[empty($empty)]"/>
+        <xsl:on-empty>There is no price data</xsl:on-empty>    
       </out>
     </xsl:stream>
   </xsl:template> 
@@ -292,8 +288,8 @@
     <xsl:stream href="../docs/books.xml">
       <out>
         <xsl:sequence select="ends-with(document-uri(), 'books.xml')[empty($empty)]"/>  
-        <xsl:on-empty>There is no price data</xsl:on-empty>
-        <xsl:sequence select="./BOOKLIST/BOOKS/ITEM/PRICEDATA"/>    
+        <xsl:sequence select="./BOOKLIST/BOOKS/ITEM/PRICEDATA"/>
+        <xsl:on-empty>There is no price data</xsl:on-empty>    
       </out>
     </xsl:stream>
   </xsl:template> 
@@ -305,8 +301,8 @@
       <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:sequence select="BOOKS/ITEM/PRICEDATA"/>
+          <xsl:on-empty>There is no price data</xsl:on-empty> 
         </xsl:for-each>
       </out>
     </xsl:stream>
@@ -318,8 +314,8 @@
     <xsl:stream href="../docs/books.xml">
       <out>
         <xsl:sequence select="(1 to 20)[. ge 20][empty($empty)]"/>  
-        <xsl:on-empty>There is no price data</xsl:on-empty>
-        <xsl:sequence select="./BOOKLIST/BOOKS/ITEM/PRICEDATA/data()"/> 
+        <xsl:sequence select="./BOOKLIST/BOOKS/ITEM/PRICEDATA/data()"/>
+        <xsl:on-empty>There is no price data</xsl:on-empty> 
       </out>
     </xsl:stream>
   </xsl:template>
@@ -330,8 +326,8 @@
     <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()"/> 
+        <xsl:sequence select="./BOOKLIST/BOOKS/ITEM/PRICE/data()"/>
+        <xsl:on-empty>There is no price data</xsl:on-empty> 
       </out>
     </xsl:stream>
   </xsl:template>
@@ -409,46 +405,6 @@
     </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">
@@ -515,6 +471,43 @@
     </xsl:stream>
   </xsl:template> 
   
+  <!-- Zero length text nodes are considered empty -->
+  
+  <xsl:template name="s-041" use-when="$RUN">
+    <xsl:stream href="../docs/books.xml">
+      <out>
+        <xsl:value-of select="string(/BOOKLIST/BOOKS/ITEM/EXPORT-QUOTA)"/>
+        <xsl:on-empty>EMPTY</xsl:on-empty>
+     </out>
+    </xsl:stream>
+  </xsl:template> 
+  
+  <!-- Childless document nodes are considered empty -->
+  
+  <xsl:template name="s-042" use-when="$RUN">
+    <xsl:stream href="../docs/books.xml">
+      <out>
+        <xsl:document>
+          <xsl:value-of select="string(/BOOKLIST/BOOKS/ITEM/EXPORT-QUOTA)"/>
+        </xsl:document>  
+        <xsl:on-empty>EMPTY</xsl:on-empty>
+     </out>
+    </xsl:stream>
+  </xsl:template> 
+  
+  <!-- Document nodes containing whitespace text are not considered empty -->
+  
+  <xsl:template name="s-043" use-when="$RUN">
+    <xsl:stream href="../docs/books.xml">
+      <out>
+        <xsl:document>
+          <xsl:value-of select="concat(' ', string(/BOOKLIST/BOOKS/ITEM/EXPORT-QUOTA), ' ')"/>
+        </xsl:document>  
+        <xsl:on-empty>EMPTY</xsl:on-empty>
+     </out>
+    </xsl:stream>
+  </xsl:template> 
+  
   
 
 
--- a/tests/strm/si-on-non-empty/_si-on-non-empty-test-set.xml	Fri Aug 14 10:00:23 2015 +0100
+++ b/tests/strm/si-on-non-empty/_si-on-non-empty-test-set.xml	Sun Aug 16 23:56:35 2015 +0100
@@ -408,6 +408,42 @@
          ><TITLE>The Big Over Easy</TITLE><TITLE>The Eyre Affair</TITLE></out>]]></assert-xml>
       </result>
    </test-case>
+   
+   <test-case name="si-on-non-empty-041">
+      <description>Zero-length text nodes are considered empty</description>
+      <created by="Michael Kay" on="2015-08-16"/>
+      <environment ref="si-on-non-empty-A"/>  
+      <test>
+         <initial-template name="s-041"/>
+      </test>
+      <result>
+         <assert-xml><![CDATA[<out/>]]></assert-xml>
+      </result>
+   </test-case>
+   
+   <test-case name="si-on-non-empty-042">
+      <description>Childless document nodes are considered empty</description>
+      <created by="Michael Kay" on="2015-08-16"/>
+      <environment ref="si-on-non-empty-A"/>  
+      <test>
+         <initial-template name="s-042"/>
+      </test>
+      <result>
+         <assert-xml><![CDATA[<out/>]]></assert-xml>
+      </result>
+   </test-case>
+   
+   <test-case name="si-on-non-empty-043">
+      <description>Document nodes containing whitespace text nodes not are considered empty</description>
+      <created by="Michael Kay" on="2015-08-16"/>
+      <environment ref="si-on-non-empty-A"/>  
+      <test>
+         <initial-template name="s-043"/>
+      </test>
+      <result>
+         <assert-xml><![CDATA[<out>*  *</out>]]></assert-xml>
+      </result>
+   </test-case>
 
 
 </test-set>
\ No newline at end of file
--- a/tests/strm/si-on-non-empty/si-on-non-empty-A.xsl	Fri Aug 14 10:00:23 2015 +0100
+++ b/tests/strm/si-on-non-empty/si-on-non-empty-A.xsl	Sun Aug 16 23:56:35 2015 +0100
@@ -514,6 +514,44 @@
     </xsl:stream>
   </xsl:template> 
   
+  <!-- Zero length text nodes are considered empty -->
+  
+  <xsl:template name="s-041" use-when="$RUN">
+    <xsl:stream href="../docs/books.xml">
+      <out>
+        <xsl:value-of select="string(/BOOKLIST/BOOKS/ITEM/EXPORT-QUOTA)"/>
+        <xsl:on-non-empty>WRONG</xsl:on-non-empty>
+     </out>
+    </xsl:stream>
+  </xsl:template> 
+  
+  <!-- Childless document nodes are considered empty -->
+  
+  <xsl:template name="s-042" use-when="$RUN">
+    <xsl:stream href="../docs/books.xml">
+      <out>
+        <xsl:document>
+          <xsl:value-of select="string(/BOOKLIST/BOOKS/ITEM/EXPORT-QUOTA)"/>
+        </xsl:document>  
+        <xsl:on-non-empty>WRONG</xsl:on-non-empty>
+     </out>
+    </xsl:stream>
+  </xsl:template> 
+  
+  <!-- Document nodes containing whitespace text are not considered empty -->
+  
+  <xsl:template name="s-043" use-when="$RUN">
+    <xsl:stream href="../docs/books.xml">
+      <out>
+        <xsl:on-non-empty>*</xsl:on-non-empty>
+        <xsl:document>
+          <xsl:value-of select="concat(' ', string(/BOOKLIST/BOOKS/ITEM/EXPORT-QUOTA), ' ')"/>
+        </xsl:document>  
+        <xsl:on-non-empty>*</xsl:on-non-empty>
+     </out>
+    </xsl:stream>
+  </xsl:template> 
+