More xsl:conditional-content tests (streamed and unstreamed)
authorMichael Kay <mike@saxonica.com>
Fri, 14 Aug 2015 10:00:23 +0100
changeset 1041 96cb3048ae26
parent 1040 45899ebba0f0
child 1042 62fbcfcc2c5d
More xsl:conditional-content tests (streamed and unstreamed)
tests/insn/conditional-content/_conditional-content-test-set.xml
tests/insn/conditional-content/conditional-content-A.xsl
tests/strm/si-conditional-content/_si-conditional-content-test-set.xml
tests/strm/si-conditional-content/si-conditional-content-A.xsl
--- a/tests/insn/conditional-content/_conditional-content-test-set.xml	Thu Aug 13 22:37:08 2015 +0100
+++ b/tests/insn/conditional-content/_conditional-content-test-set.xml	Fri Aug 14 10:00:23 2015 +0100
@@ -137,6 +137,7 @@
    <test-case name="coco-011">
       <description>Test of xsl:conditional-content with xsl:fork</description>
       <created by="Michael Kay" on="2015-08-13"/>
+      <environment ref="coco-A"/> 
       <test>
          <initial-template name="s-011"/>
       </test>
@@ -180,7 +181,89 @@
          <assert>/out/in/@count = '1'</assert>
       </result>
    </test-case>
-
-
+   
+   <test-case name="coco-015">
+      <description> Test of xsl:conditional-content with elements having attributes </description>
+      <created by="Michael Kay" on="2015-08-14"/>
+      <environment ref="coco-A"/>  
+      <test>
+         <initial-template name="s-015"/>
+      </test>
+      <result>
+         <assert-xml><![CDATA[<Results><first one="non-empty">one</first><third xmlns:x="http://abc.com/">three</third></Results>]]></assert-xml>
+      </result>
+   </test-case>
+   
+   <test-case name="coco-016">
+      <description> Test of xsl:conditional-content with free-standing attributes </description>
+      <created by="Michael Kay" on="2015-08-14"/>
+      <environment ref="coco-A"/>  
+      <test>
+         <initial-template name="s-016"/>
+      </test>
+      <result>
+         <assert-xml><![CDATA[<Results x="17"/>]]></assert-xml>
+      </result>
+   </test-case>
+   
+   <test-case name="coco-017">
+      <description> Test of xsl:conditional-content with namespace with empty name: error </description>
+      <created by="Michael Kay" on="2015-08-14"/>
+      <environment ref="coco-A"/>  
+      <test>
+         <initial-template name="s-017"/>
+      </test>
+      <result>
+         <error code="XTDE0930"/>
+      </result>
+   </test-case>
+   
+   <test-case name="coco-018">
+      <description> Test of xsl:conditional-content with empty text nodes </description>
+      <created by="Michael Kay" on="2015-08-14"/>
+      <environment ref="coco-A"/>  
+      <test>
+         <initial-template name="s-018"/>
+      </test>
+      <result>
+         <assert>/Results = '17 92 55=17 92 55'</assert>
+      </result>
+   </test-case>
+   
+   <test-case name="coco-019">
+      <description> Test of xsl:conditional-content with empty comments </description>
+      <created by="Michael Kay" on="2015-08-14"/>
+      <environment ref="coco-A"/>  
+      <test>
+         <initial-template name="s-019"/>
+      </test>
+      <result>
+         <assert-xml><![CDATA[<Results>1:<!--Pride and Prejudice-->2:</Results>]]></assert-xml>
+      </result>
+   </test-case>
+   
+   <test-case name="coco-020">
+      <description> Test of xsl:conditional-content with empty processing instructions </description>
+      <created by="Michael Kay" on="2015-08-14"/>
+      <environment ref="coco-A"/>  
+      <test>
+         <initial-template name="s-020"/>
+      </test>
+      <result>
+         <assert-xml><![CDATA[<Results>1:<?mu Pride and Prejudice?>2:</Results>]]></assert-xml>
+      </result>
+   </test-case>
+   
+   <test-case name="coco-021">
+      <description> Test of xsl:conditional-content including local variables </description>
+      <created by="Michael Kay" on="2015-08-14"/>
+      <environment ref="coco-A"/>  
+      <test>
+         <initial-template name="s-021"/>
+      </test>
+      <result>
+         <assert-xml><![CDATA[<Results><b>2222</b><b>2222</b></Results>]]></assert-xml>
+      </result>
+   </test-case>
 
 </test-set>
\ No newline at end of file
--- a/tests/insn/conditional-content/conditional-content-A.xsl	Thu Aug 13 22:37:08 2015 +0100
+++ b/tests/insn/conditional-content/conditional-content-A.xsl	Fri Aug 14 10:00:23 2015 +0100
@@ -6,7 +6,8 @@
   <xsl:variable name="RUN" select="true()" static="yes"/>
   <xsl:strip-space elements="*"/>
 
-  <xsl:variable name="doc" select="/"/>
+  <xsl:param name="doc" select="/"/>
+  <xsl:param name="zls" select="''"/>
  
   <!-- Test of xsl:conditional-content with xsl:element (not empty) -->
 
@@ -240,9 +241,118 @@
         <in count="{count($m)}"/>     
       </out>
     </xsl:for-each>
-  </xsl:template> 
+  </xsl:template>
+  
+  <!-- Test of xsl:conditional-content with elements having attributes and namespaces -->
+  
+  <xsl:template name="s-015" use-when="$RUN">
+       <xsl:for-each select="$doc">
+           <Results>
+               <xsl:conditional-content>
+                 <first one='non-empty'>one</first>
+                 <second one='empty'/>
+                 <third xmlns:x='http://abc.com/'>three</third>
+                 <fourth xmlns:x='http://abc.com/'/>
+               </xsl:conditional-content>
+           </Results>
+       </xsl:for-each>
+   </xsl:template>  
+   
+   <!-- Test of xsl:conditional-content with free-standing attributes -->
+  
+  <xsl:template name="s-016" use-when="$RUN">
+       <xsl:for-each select="$doc">
+           <Results>
+               <xsl:conditional-content>
+                 <xsl:attribute name="x" select="17"/>
+                 <xsl:attribute name="x" select="''"/>
+                 <inner/>
+                 <xsl:attribute name="y" select="substring(string(current-date()), 842)"/>
+               </xsl:conditional-content>
+           </Results>
+       </xsl:for-each>
+   </xsl:template>  
+   
+   <!-- A namespace node with zero-length string value is an error even within conditional-content -->
+  
+  <xsl:template name="s-017" use-when="$RUN">
+       <xsl:for-each select="$doc">
+           <Results>
+               <xsl:conditional-content>
+                 <xsl:namespace name="x" select="substring(string(current-date()), 842)"/>
+               </xsl:conditional-content>
+           </Results>
+       </xsl:for-each>
+   </xsl:template>
+   
+   <!-- Test of xsl:conditional-content with zero-length text nodes. Note that these are
+   eliminated before the "constructing complex content" rules come into play, so atomic values
+   either side become adjacent. -->
+  
+  <xsl:template name="s-018" use-when="$RUN">
+       <xsl:for-each select="$doc">
+           <Results>
+               <xsl:conditional-content>
+                 <xsl:sequence select="17"/>
+                 <xsl:value-of select="//yankee-doodle"/>
+                 <xsl:sequence select="92"/>
+                 <xsl:text/>
+                 <xsl:sequence select="55"/>
+                 <xsl:text>=</xsl:text>
+                 <xsl:value-of>17 92 55</xsl:value-of>
+               </xsl:conditional-content>
+           </Results>
+       </xsl:for-each>
+   </xsl:template>  
+   
+   <!-- Test of xsl:conditional-content with zero-length comments. -->
+  
+  <xsl:template name="s-019" use-when="$RUN">
+       <xsl:for-each select="$doc">
+           <Results>
+               <xsl:conditional-content>
+                 <xsl:text>1:</xsl:text>
+                 <xsl:comment select="head(//TITLE)"/>
+                 <xsl:text>2:</xsl:text>
+                 <xsl:comment select="unparsed-entity-uri('fandango')"/>
+               </xsl:conditional-content>
+           </Results>
+       </xsl:for-each>
+   </xsl:template>     
+   
+   <!-- Test of xsl:conditional-content with zero-length processing-instructions. -->
+  
+  <xsl:template name="s-020" use-when="$RUN">
+       <xsl:for-each select="$doc">
+           <Results>
+               <xsl:conditional-content>
+                 <xsl:text>1:</xsl:text>
+                 <xsl:processing-instruction name="mu" select="head(//TITLE)"/>
+                 <xsl:text>2:</xsl:text>
+                 <xsl:processing-instruction name="pi" select="unparsed-entity-uri('fandango')"/>
+               </xsl:conditional-content>
+           </Results>
+       </xsl:for-each>
+   </xsl:template>     
  
-
+<!-- Test of xsl:conditional-content including local variables. -->
+  
+  <xsl:template name="s-021" use-when="$RUN">
+       <xsl:for-each select="$doc">
+           <Results>
+               <xsl:conditional-content>
+                 <xsl:variable name="x" select="$zls"/>
+                 <xsl:variable name="y" select="name(.)||22"/>
+                 <a><xsl:value-of select="$x||$x"/></a>
+                 <b><xsl:value-of select="$y||$y"/></b>
+                 <xsl:variable name="xx" select="$zls"/>
+                 <xsl:variable name="yy" select="name(.)||22"/>
+                 <a><xsl:value-of select="$xx||$xx"/></a>
+                 <b><xsl:value-of select="$yy||$yy"/></b>
+               </xsl:conditional-content>
+           </Results>
+       </xsl:for-each>
+   </xsl:template> 
 
 
 
--- a/tests/strm/si-conditional-content/_si-conditional-content-test-set.xml	Thu Aug 13 22:37:08 2015 +0100
+++ b/tests/strm/si-conditional-content/_si-conditional-content-test-set.xml	Fri Aug 14 10:00:23 2015 +0100
@@ -182,6 +182,90 @@
       </result>
    </test-case>
 
+   <test-case name="si-coco-015">
+      <description> Test of xsl:conditional-content with elements having attributes </description>
+      <created by="Michael Kay" on="2015-08-14"/>
+      <environment ref="si-coco-A"/>  
+      <test>
+         <initial-template name="s-015"/>
+      </test>
+      <result>
+         <assert-xml><![CDATA[<Results><first one="non-empty">one</first><third xmlns:x="http://abc.com/">three</third></Results>]]></assert-xml>
+      </result>
+   </test-case>
+   
+   <test-case name="si-coco-016">
+      <description> Test of xsl:conditional-content with free-standing attributes </description>
+      <created by="Michael Kay" on="2015-08-14"/>
+      <environment ref="si-coco-A"/>  
+      <test>
+         <initial-template name="s-016"/>
+      </test>
+      <result>
+         <assert-xml><![CDATA[<Results x="17"/>]]></assert-xml>
+      </result>
+   </test-case>
+   
+   <test-case name="si-coco-017">
+      <description> Test of xsl:conditional-content with namespace with empty name: error </description>
+      <created by="Michael Kay" on="2015-08-14"/>
+      <environment ref="si-coco-A"/>  
+      <test>
+         <initial-template name="s-017"/>
+      </test>
+      <result>
+         <error code="XTDE0930"/>
+      </result>
+   </test-case>
+   
+   <test-case name="si-coco-018">
+      <description> Test of xsl:conditional-content with empty text nodes </description>
+      <created by="Michael Kay" on="2015-08-14"/>
+      <environment ref="si-coco-A"/>  
+      <test>
+         <initial-template name="s-018"/>
+      </test>
+      <result>
+         <assert>/Results = '17 92 55=17 92 55'</assert>
+      </result>
+   </test-case>
+   
+   <test-case name="si-coco-019">
+      <description> Test of xsl:conditional-content with empty comments </description>
+      <created by="Michael Kay" on="2015-08-14"/>
+      <environment ref="si-coco-A"/>  
+      <test>
+         <initial-template name="s-019"/>
+      </test>
+      <result>
+         <assert-xml><![CDATA[<Results>1:<!--Pride and Prejudice-->2:</Results>]]></assert-xml>
+      </result>
+   </test-case>
+   
+   <test-case name="si-coco-020">
+      <description> Test of xsl:conditional-content with empty processing instructions </description>
+      <created by="Michael Kay" on="2015-08-14"/>
+      <environment ref="si-coco-A"/>  
+      <test>
+         <initial-template name="s-020"/>
+      </test>
+      <result>
+         <assert-xml><![CDATA[<Results>1:<?mu Pride and Prejudice?>2:</Results>]]></assert-xml>
+      </result>
+   </test-case>
+   
+   <test-case name="si-coco-021">
+      <description> Test of xsl:conditional-content including local variables </description>
+      <created by="Michael Kay" on="2015-08-14"/>
+      <environment ref="si-coco-A"/>  
+      <test>
+         <initial-template name="s-021"/>
+      </test>
+      <result>
+         <assert-xml><![CDATA[<Results><b>2222</b><b>2222</b></Results>]]></assert-xml>
+      </result>
+   </test-case>
+   
 
 
 </test-set>
\ No newline at end of file
--- a/tests/strm/si-conditional-content/si-conditional-content-A.xsl	Thu Aug 13 22:37:08 2015 +0100
+++ b/tests/strm/si-conditional-content/si-conditional-content-A.xsl	Fri Aug 14 10:00:23 2015 +0100
@@ -241,6 +241,117 @@
     </xsl:stream>
   </xsl:template> 
  
+  <!-- Test of xsl:conditional-content with elements having attributes and namespaces -->
+  
+  <xsl:template name="s-015" use-when="$RUN">
+       <xsl:stream href="../docs/books.xml">
+           <Results>
+               <xsl:conditional-content>
+                 <first one='non-empty'>one</first>
+                 <second one='empty'/>
+                 <third xmlns:x='http://abc.com/'>three</third>
+                 <fourth xmlns:x='http://abc.com/'/>
+               </xsl:conditional-content>
+           </Results>
+       </xsl:stream>
+   </xsl:template>  
+   
+   <!-- Test of xsl:conditional-content with free-standing attributes -->
+  
+  <xsl:template name="s-016" use-when="$RUN">
+       <xsl:stream href="../docs/books.xml">
+           <Results>
+               <xsl:conditional-content>
+                 <xsl:attribute name="x" select="17"/>
+                 <xsl:attribute name="x" select="''"/>
+                 <inner/>
+                 <xsl:attribute name="y" select="substring(string(current-date()), 842)"/>
+               </xsl:conditional-content>
+           </Results>
+       </xsl:stream>
+   </xsl:template>  
+   
+   <!-- A namespace node with zero-length string value is an error even within conditional-content -->
+  
+  <xsl:template name="s-017" use-when="$RUN">
+       <xsl:stream href="../docs/books.xml">
+           <Results>
+               <xsl:conditional-content>
+                 <xsl:namespace name="x" select="substring(string(current-date()), 842)"/>
+               </xsl:conditional-content>
+           </Results>
+       </xsl:stream>
+   </xsl:template>
+   
+   <!-- Test of xsl:conditional-content with zero-length text nodes. Note that these are
+   eliminated before the "constructing complex content" rules come into play, so atomic values
+   either side become adjacent. -->
+  
+  <xsl:template name="s-018" use-when="$RUN">
+       <xsl:stream href="../docs/books.xml">
+           <Results>
+               <xsl:conditional-content>
+                 <xsl:sequence select="17"/>
+                 <xsl:value-of select="//yankee-doodle"/>
+                 <xsl:sequence select="92"/>
+                 <xsl:text/>
+                 <xsl:sequence select="55"/>
+                 <xsl:text>=</xsl:text>
+                 <xsl:value-of>17 92 55</xsl:value-of>
+               </xsl:conditional-content>
+           </Results>
+       </xsl:stream>
+   </xsl:template>  
+   
+   <!-- Test of xsl:conditional-content with zero-length comments. -->
+  
+  <xsl:template name="s-019" use-when="$RUN">
+       <xsl:stream href="../docs/books.xml">
+           <Results>
+               <xsl:conditional-content>
+                 <xsl:text>1:</xsl:text>
+                 <xsl:comment select="head(//TITLE)"/>
+                 <xsl:text>2:</xsl:text>
+                 <xsl:comment select="unparsed-entity-uri('fandango')"/>
+               </xsl:conditional-content>
+           </Results>
+       </xsl:stream>
+   </xsl:template>     
+   
+   <!-- Test of xsl:conditional-content with zero-length processing-instructions. -->
+  
+  <xsl:template name="s-020" use-when="$RUN">
+       <xsl:stream href="../docs/books.xml">
+           <Results>
+               <xsl:conditional-content>
+                 <xsl:text>1:</xsl:text>
+                 <xsl:processing-instruction name="mu" select="head(//TITLE)"/>
+                 <xsl:text>2:</xsl:text>
+                 <xsl:processing-instruction name="pi" select="unparsed-entity-uri('fandango')"/>
+               </xsl:conditional-content>
+           </Results>
+       </xsl:stream>
+   </xsl:template>
+   
+   <!-- Test of xsl:conditional-content including local variables. -->
+  
+  <xsl:template name="s-021" use-when="$RUN">
+       <xsl:stream href="../docs/books.xml">
+           <Results>
+               <xsl:conditional-content>
+                 <xsl:variable name="x"/>
+                 <xsl:variable name="y" select="22"/>
+                 <a><xsl:value-of select="$x||$x"/></a>
+                 <b><xsl:value-of select="$y||$y"/></b>
+                 <xsl:variable name="xx"/>
+                 <xsl:variable name="yy" select="22"/>
+                 <a><xsl:value-of select="$xx||$xx"/></a>
+                 <b><xsl:value-of select="$yy||$yy"/></b>
+               </xsl:conditional-content>
+           </Results>
+       </xsl:stream>
+   </xsl:template>         
+