Fix various tests affected by on-empty spec changes
authorMichael Kay <mike@saxonica.com>
Tue, 11 Aug 2015 17:58:16 +0100
changeset 1025 17b24d9f546b
parent 1024 28342569f383
child 1026 238fd578d417
Fix various tests affected by on-empty spec changes
tests/strm/docs/loans.xsd
tests/strm/si-element/_si-element-test-set.xml
tests/strm/si-element/si-element-A.xsl
tests/strm/si-element/si-element-B.xsl
--- a/tests/strm/docs/loans.xsd	Tue Aug 11 17:57:29 2015 +0100
+++ b/tests/strm/docs/loans.xsd	Tue Aug 11 17:58:16 2015 +0100
@@ -1558,4 +1558,6 @@
             </xs:enumeration>
         </xs:restriction>
     </xs:simpleType>
+    
+    <xs:element name="processingDate" type="xs:date"/>
 </xs:schema>
--- a/tests/strm/si-element/_si-element-test-set.xml	Tue Aug 11 17:57:29 2015 +0100
+++ b/tests/strm/si-element/_si-element-test-set.xml	Tue Aug 11 17:58:16 2015 +0100
@@ -292,6 +292,7 @@
    <test-case name="si-element-044">
       <description>Use xsl:element: with on-empty</description>
       <created by="Michael Kay" on="2013-12-19"/>
+      <modified by="Michael Kay" on="2015-08-11" change="corrected test (removed unintended dynamic error)"/>
       <environment ref="si-element-A"/>
       <test>
          <initial-template name="cy-044"/>
@@ -304,6 +305,7 @@
    <test-case name="si-element-045">
       <description>Use xsl:element: with on-empty</description>
       <created by="Michael Kay" on="2013-12-19"/>
+      <modified by="Michael Kay" on="2015-08-11" change="corrected test (removed unintended dynamic error)"/>
       <environment ref="si-element-A"/>
       <test>
          <initial-template name="cy-045"/>
@@ -607,6 +609,7 @@
    <test-case name="si-element-118">
       <description>Use xsl: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-element-B"/>
       <dependencies>
         <feature value="schema_aware"/>
@@ -615,13 +618,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-element-119">
       <description>Use xsl: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-element-B"/>
       <dependencies>
         <feature value="schema_aware"/>
@@ -630,13 +634,14 @@
          <initial-template name="cy-119"/>
       </test>
       <result>
-         <error code="XTTE1512"/>
+         <error code="XTTE1510"/>
       </result>
    </test-case>
    
    <test-case name="si-element-120">
       <description>Use xsl: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-element-B"/>
       <dependencies>
         <feature value="schema_aware"/>
@@ -645,13 +650,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-element-121">
       <description>Use xsl: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-element-B"/>
       <dependencies>
         <feature value="schema_aware"/>
@@ -1052,14 +1058,16 @@
    </test-case>
    
    <test-case name="si-element-255">
-      <description>xsl:element; select is consuming, on-empty is multiple elements - type error</description>
+      <description>xsl:element; select is consuming, on-empty is multiple elements - 
+        (empty, no longer a type error, returns two elements)</description>
       <created by="Michael Kay" on="2014-01-06"/>
+      <modified by="Michael Kay" on="2015-08-11" change="correct expected results"/>
       <environment ref="si-element-C"/>
       <test>
          <initial-template name="s-055"/>
       </test>
       <result>
-         <error code="XTTE3310"/>
+         <assert-xml><![CDATA[<out><n1>1</n1><n2>2</n2></out>]]></assert-xml>
       </result>
    </test-case>
    
--- a/tests/strm/si-element/si-element-A.xsl	Tue Aug 11 17:57:29 2015 +0100
+++ b/tests/strm/si-element/si-element-A.xsl	Tue Aug 11 17:58:16 2015 +0100
@@ -352,7 +352,7 @@
       </xsl:variable>
       <xsl:stream href="../docs/special.xml">
         <xsl:conditional-content>
-          <xsl:element name="{name(.)}" namespace="{namespace-uri(.)}">
+          <xsl:element name="{name($a)}" namespace="{namespace-uri($a)}">
             <xsl:if test="current-date() lt xs:date('1900-01-01')">
               <xsl:sequence select="special/comment()[2]"/>
             </xsl:if>
@@ -372,7 +372,7 @@
       </xsl:variable>
       <xsl:stream href="../docs/special.xml">
         <xsl:conditional-content>
-          <xsl:element name="{name(.)}" namespace="{namespace-uri(.)}">
+          <xsl:element name="{name($a)}" namespace="{namespace-uri($a)}">
             <xsl:if test="current-date() lt xs:date('1900-01-01')">
               <xsl:sequence select="special/processing-instruction()[2]"/>
             </xsl:if>
--- a/tests/strm/si-element/si-element-B.xsl	Tue Aug 11 17:57:29 2015 +0100
+++ b/tests/strm/si-element/si-element-B.xsl	Tue Aug 11 17:58:16 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:conditional-content>
-            <xsl:for-each select="*">
-              <xsl:element name="{name(.)}" namespace="{namespace-uri(.)}" validation="strict">
+            <xsl:for-each select="head(//PoolIdentifier)">
+              <xsl:element name="processingDate" validation="strict">
                 <xsl:copy-of select="*/*/NONEXISTENT"/>
+                <xsl:on-empty select="'2015-08-11'"/>
               </xsl:element>
             </xsl:for-each>
           </xsl:conditional-content>
-        </xsl:variable>
-        <xsl:value-of select="empty($copy)"/>
       </xsl:stream>
     </out>
   </xsl:template>
@@ -317,22 +315,16 @@
   <!-- within xsl:stream, use xsl:element: 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:conditional-content>
-            <xsl:for-each select="*">
-              <xsl:element name="{name(.)}" namespace="{namespace-uri(.)}" validation="strict">
+        <xsl:conditional-content>
+            <xsl:for-each select="head(//PoolIdentifier)">
+              <xsl:element  name="processingDate" validation="strict">
                 <xsl:copy-of select="*/*/NONEXISTENT"/>
+                <xsl:on-empty select="'NOT_A_NUMBER'"/>
               </xsl:element>
             </xsl:for-each>
           </xsl:conditional-content>
-          <xsl:on-empty select="$e"/>
-        </xsl:variable>
-        <xsl:value-of select="empty($copy)"/>
       </xsl:stream>
     </out>
   </xsl:template>
@@ -340,24 +332,16 @@
   <!-- within xsl:stream, use xsl:element: 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:stream href="../docs/loans-noNS.xml">
           <xsl:conditional-content>
-            <xsl:for-each select="*">
-              <xsl:element name="{name(.)}" namespace="{namespace-uri(.)}" type="xs:integer">
-                <xsl:value-of select="*/*/NONEXISTENT"/>
+            <xsl:for-each select="head(//PoolIdentifier)">
+              <xsl:element name="{name(.)}" namespace="{namespace-uri(.)}" type="FmIdentifierInt">
+                <xsl:copy-of select="*/*/NONEXISTENT"/>
+                <xsl:on-empty select="29"/>
               </xsl:element>
             </xsl:for-each>
           </xsl:conditional-content>
-          <xsl:on-empty>
-            <xsl:copy-of select="$e" validation="strict"/>
-          </xsl:on-empty>
-        </xsl:variable>
-        <xsl:copy-of select="$copy"/>
       </xsl:stream>
     </out>
   </xsl:template>
@@ -365,22 +349,16 @@
   <!-- within xsl:stream, use xsl:element: 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:conditional-content>
-            <xsl:for-each select="*">
-              <xsl:element name="{name(.)}" namespace="{namespace-uri(.)}" type="xs:integer">
-                <xsl:value-of select="*/*/NONEXISTENT"/>
+            <xsl:for-each select="head(//PoolIdentifier)">
+              <xsl:element name="{name(.)}" namespace="{namespace-uri(.)}" type="FmIdentifierInt">
+                <xsl:copy-of select="*/*/NONEXISTENT"/>
+                <xsl:on-empty select="'NOT_A_NUMBER'"/>
               </xsl:element>
             </xsl:for-each>
           </xsl:conditional-content>
-          <xsl:on-empty select="$e"/>
-        </xsl:variable>
-        <xsl:value-of select="empty($copy)"/>
       </xsl:stream>
     </out>
   </xsl:template>