Rewrite some LRE tests to the new on-empty spec
authorMichael Kay <mike@saxonica.com>
Thu, 13 Aug 2015 10:43:31 +0100
changeset 1035 beaaed2912d9
parent 1034 412d4f6bb7bf
child 1036 8b4d0d1981b4
Rewrite some LRE tests to the new on-empty spec
tests/strm/si-LRE/_si-lre-test-set.xml
tests/strm/si-LRE/si-lre-B.xsl
tests/strm/si-LRE/si-lre-C.xsl
--- a/tests/strm/si-LRE/_si-lre-test-set.xml	Wed Aug 12 14:23:07 2015 +0100
+++ b/tests/strm/si-LRE/_si-lre-test-set.xml	Thu Aug 13 10:43:31 2015 +0100
@@ -604,6 +604,7 @@
    <test-case name="si-lre-118">
       <description>Use literal result element: schema-aware, validation; on-empty must be empty or valid</description>
       <created by="Michael Kay" on="2014-01-09"/>
+      <modified by="Michael Kay" on="2015-08-11" change="Rewrite test to do what it says on the tin"/>
       <environment ref="si-lre-B"/>
       <dependencies>
         <feature value="schema_aware"/>
@@ -612,13 +613,14 @@
          <initial-template name="cy-118"/>
       </test>
       <result>
-         <assert>/out = 'true'</assert>
+         <assert>/out/processingDate = '2015-08-11'</assert>
       </result>
    </test-case>
    
    <test-case name="si-lre-119">
       <description>Use literal result element: schema-aware, validation; on-empty must be empty or valid</description>
       <created by="Michael Kay" on="2014-01-09"/>
+      <modified by="Michael Kay" on="2015-08-11" change="Rewrite test to do what it says on the tin"/>
       <environment ref="si-lre-B"/>
       <dependencies>
         <feature value="schema_aware"/>
@@ -627,13 +629,14 @@
          <initial-template name="cy-119"/>
       </test>
       <result>
-         <error code="XTTE1512"/>
+         <error code="XTTE1510"/>
       </result>
    </test-case>
    
    <test-case name="si-lre-120">
       <description>Use literal result element: schema-aware, validation; on-empty must be empty or valid</description>
       <created by="Michael Kay" on="2014-01-09"/>
+      <modified by="Michael Kay" on="2015-08-11" change="Rewrite test to do what it says on the tin"/>
       <environment ref="si-lre-B"/>
       <dependencies>
         <feature value="schema_aware"/>
@@ -642,13 +645,14 @@
          <initial-template name="cy-120"/>
       </test>
       <result>
-         <assert>/out/e = '2'</assert>
+         <assert>/out/PoolIdentifier = '29'</assert>
       </result>
    </test-case>
    
    <test-case name="si-lre-121">
       <description>Use literal result element: schema-aware, validation; on-empty must be empty or valid</description>
       <created by="Michael Kay" on="2014-01-09"/>
+      <modified by="Michael Kay" on="2015-08-11" change="Rewrite test to do what it says on the tin"/>
       <environment ref="si-lre-B"/>
       <dependencies>
         <feature value="schema_aware"/>
@@ -1036,6 +1040,7 @@
    <test-case name="si-lre-253">
       <description>literal result element; on-empty expression is consuming, and is activated</description>
       <created by="Michael Kay" on="2014-01-06"/>
+      <modified by="Michael Kay" on="2015-08-13" change="Correct test to produce expected results"/>
       <environment ref="si-lre-C"/>
       <test>
          <initial-template name="s-053"/>
@@ -1058,26 +1063,15 @@
    </test-case>
    
    <test-case name="si-lre-255">
-      <description>literal result element; select is consuming, on-empty is multiple elements - type error</description>
+      <description>literal result element; select is consuming, on-empty is multiple elements</description>
       <created by="Michael Kay" on="2014-01-06"/>
+      <modified by="Michael Kay" on="2015-08-13" change="No longer a type error"/>
       <environment ref="si-lre-C"/>
       <test>
          <initial-template name="s-055"/>
       </test>
       <result>
-         <error code="XTTE3310"/>
-      </result>
-   </test-case>
-   
-   <test-case name="si-lre-256">
-      <description>literal result element; select is consuming, on-empty is multiple elements - type error - caught</description>
-      <created by="Michael Kay" on="2014-01-06"/>
-      <environment ref="si-lre-C"/>
-      <test>
-         <initial-template name="s-056"/>
-      </test>
-      <result>
-         <assert>/out/fallback = 'OK'</assert>
+         <assert-xml><![CDATA[<out><n1>1</n1><n2>2</n2></out>]]></assert-xml>
       </result>
    </test-case>
    
--- a/tests/strm/si-LRE/si-lre-B.xsl	Wed Aug 12 14:23:07 2015 +0100
+++ b/tests/strm/si-LRE/si-lre-B.xsl	Thu Aug 13 10:43:31 2015 +0100
@@ -300,16 +300,14 @@
   <xsl:template name="cy-118" use-when="$RUN">
     <out>
       <xsl:stream href="../docs/loans-noNS.xml">
-        <xsl:variable name="copy" as="node()?">
-          <xsl:for-each select="*">
-            <xsl:conditional-content>
-              <myroot xsl:validation="strict">
+          <xsl:conditional-content>
+            <xsl:for-each select="head(//PoolIdentifier)">
+              <processingDate xsl:validation="strict">
                 <xsl:copy-of select="*/*/NONEXISTENT"/>
-              </myroot>
-            </xsl:conditional-content>
-          </xsl:for-each>
-        </xsl:variable>
-        <xsl:value-of select="empty($copy)"/>
+                <xsl:on-empty select="'2015-08-11'"/>
+              </processingDate>
+            </xsl:for-each>
+          </xsl:conditional-content>
       </xsl:stream>
     </out>
   </xsl:template>
@@ -317,20 +315,16 @@
   <!-- within xsl:stream, use LRE: schema-aware, validation=strict, on-empty must be empty or valid -->
 
   <xsl:template name="cy-119" use-when="$RUN">
-    <xsl:variable name="e" as="element()">
-      <e/>
-    </xsl:variable>
     <out>
       <xsl:stream href="../docs/loans-noNS.xml">
-        <xsl:variable name="copy" as="node()?">
-          <xsl:for-each select="*">
-            <myroot xsl:validation="strict">
-              <xsl:copy-of select="*/*/NONEXISTENT"/>
-              <xsl:on-empty select="$e"/>
-            </myroot>
-          </xsl:for-each>
-        </xsl:variable>
-        <xsl:value-of select="empty($copy)"/>
+        <xsl:conditional-content>
+            <xsl:for-each select="head(//PoolIdentifier)">
+              <processingDate xsl:validation="strict">
+                <xsl:copy-of select="*/*/NONEXISTENT"/>
+                <xsl:on-empty select="'NOT_A_NUMBER'"/>
+              </processingDate>
+            </xsl:for-each>
+          </xsl:conditional-content>
       </xsl:stream>
     </out>
   </xsl:template>
@@ -338,20 +332,16 @@
   <!-- within xsl:stream, use LRE: schema-aware, validation by type, on-empty must be empty or valid -->
 
   <xsl:template name="cy-120" use-when="$RUN">
-    <xsl:variable name="e" as="element()">
-      <e>2</e>
-    </xsl:variable>
     <out>
       <xsl:stream href="../docs/loans-noNS.xml">
-        <xsl:variable name="copy" as="node()?">
-          <xsl:for-each select="*">
-            <myroot xsl:type="xs:integer">
-              <xsl:sequence select="*/*/NONEXISTENT/data()"/>
-              <xsl:on-empty select="$e"/>
-            </myroot>
-          </xsl:for-each>
-        </xsl:variable>
-        <xsl:copy-of select="$copy"/>
+          <xsl:conditional-content>
+            <xsl:for-each select="head(//PoolIdentifier)">
+              <PoolIdentifier xsl:type="FmIdentifierInt">
+                <xsl:copy-of select="*/*/NONEXISTENT"/>
+                <xsl:on-empty select="29"/>
+              </PoolIdentifier>
+            </xsl:for-each>
+          </xsl:conditional-content>
       </xsl:stream>
     </out>
   </xsl:template>
@@ -359,20 +349,16 @@
   <!-- within xsl:stream, use LRE: schema-aware, validation by type, on-empty must be empty or valid -->
 
   <xsl:template name="cy-121" use-when="$RUN">
-    <xsl:variable name="e" as="element()">
-      <e>2.7</e>
-    </xsl:variable>
     <out>
       <xsl:stream href="../docs/loans-noNS.xml">
-        <xsl:variable name="copy" as="node()?">
-          <xsl:for-each select="*">
-            <myroot xsl:type="xs:integer">
-              <xsl:sequence select="*/*/NONEXISTENT/data()"/>
-              <xsl:on-empty select="$e"/>
-            </myroot>
-          </xsl:for-each>
-        </xsl:variable>
-        <xsl:value-of select="empty($copy)"/>
+          <xsl:conditional-content>
+            <xsl:for-each select="head(//PoolIdentifier)">
+              <PoolIdentifier xsl:type="FmIdentifierInt">
+                <xsl:copy-of select="*/*/NONEXISTENT"/>
+                <xsl:on-empty select="'NOT_A_NUMBER'"/>
+              </PoolIdentifier>
+            </xsl:for-each>
+          </xsl:conditional-content>
       </xsl:stream>
     </out>
   </xsl:template>
--- a/tests/strm/si-LRE/si-lre-C.xsl	Wed Aug 12 14:23:07 2015 +0100
+++ b/tests/strm/si-LRE/si-lre-C.xsl	Thu Aug 13 10:43:31 2015 +0100
@@ -348,10 +348,8 @@
       <xsl:param name="s" select="20"/>
       <xsl:stream href="../docs/books.xml">
         <out>
-          <a>
             <xsl:sequence select="$s to 10"/>
             <xsl:on-empty select="head(//TITLE)"/>
-          </a>
         </out>
       </xsl:stream>
     </xsl:template>
@@ -393,32 +391,6 @@
       </xsl:stream>
     </xsl:template>
     
-    <!-- Test of xsl:stream with literal result element/@xsl:on-empty (empty, type error, returns two elements, recovered) -->
-    
-    <xsl:template name="s-056" use-when="$RUN">
-      <xsl:param name="n" select="2"/>
-      <xsl:variable name="atts" as="element()*">
-        <xsl:for-each select="1 to $n">
-          <a name="n{.}"><xsl:sequence select="."/></a>
-        </xsl:for-each>
-      </xsl:variable>
-      <xsl:stream href="../docs/books.xml">
-        <xsl:for-each select="BOOKLIST/BOOKS">
-          <out>
-            <xsl:try>
-              <xsl:conditional-content>
-                <a><xsl:sequence select="ITEM/PRICETAG"/></a>
-              </xsl:conditional-content>
-              <xsl:on-empty select="$atts"/>
-              <xsl:catch errors="*:XTTE3310">
-                <fallback>OK</fallback>
-              </xsl:catch>
-            </xsl:try>  
-          </out>
-        </xsl:for-each>  
-      </xsl:stream>
-    </xsl:template>
-    
     <!-- LRE content cannot contain a function item - error -->
     
     <xsl:template name="s-057" use-when="$RUN">