Add test for overridden global variable in a match pattern
authorMichael Kay <mike@saxonica.com>
Thu, 09 Jul 2015 23:10:39 +0100
changeset 1015 b7ec635012c5
parent 1014 54c229310974
child 1016 e6dbb71e09d2
Add test for overridden global variable in a match pattern
tests/decl/override/_override-test-set.xml
tests/decl/override/override-base-v-001.xsl
tests/decl/override/override-v-003.xsl
tests/decl/override/override-v-004.xsl
--- a/tests/decl/override/_override-test-set.xml	Thu Jul 09 23:10:08 2015 +0100
+++ b/tests/decl/override/_override-test-set.xml	Thu Jul 09 23:10:39 2015 +0100
@@ -415,6 +415,19 @@
       </result>
    </test-case>
    
+   <test-case name="override-v-004">
+      <description>An overridden public global variable appearing in a match pattern</description>
+      <created by="Michael Kay" on="2015-03-01"/>
+      <environment ref="override-v-C"/>
+      <test>
+         <package file="override-v-004.xsl" role="principal"/>
+         <initial-template name="main"/>
+      </test>
+      <result>
+         <assert>/go/not-one</assert>
+      </result>
+   </test-case>
+   
    <test-case name="override-as-001">
       <description>Successful override of a public attribute-set</description>
       <created by="Michael Kay" on="2015-02-28"/>
--- a/tests/decl/override/override-base-v-001.xsl	Thu Jul 09 23:10:08 2015 +0100
+++ b/tests/decl/override/override-base-v-001.xsl	Thu Jul 09 23:10:39 2015 +0100
@@ -18,6 +18,19 @@
     
     <xsl:variable name="v-base" as="xs:integer" visibility="public" select="2"/>
     
+    <xsl:template name="go" visibility="public">
+      <xsl:param name="node" as="node()"/>
+      <go><xsl:apply-templates select="$node"/></go>
+    </xsl:template>
+    
+    <xsl:template match="*[$v-public = 1]">
+      <one/>
+    </xsl:template> 
+    
+    <xsl:template match="*[$v-public != 1]">
+      <not-one/>
+    </xsl:template>   
+    
   
   
 </xsl:package>   
\ No newline at end of file
--- a/tests/decl/override/override-v-003.xsl	Thu Jul 09 23:10:08 2015 +0100
+++ b/tests/decl/override/override-v-003.xsl	Thu Jul 09 23:10:39 2015 +0100
@@ -12,7 +12,7 @@
   
     <xsl:override>
   
-      <xsl:variable name="v-public" as="xs:integer" visibility="public" select="xsl:original + 13"/>
+      <xsl:variable name="v-public" as="xs:integer" visibility="public" select="$xsl:original + 13"/>
     
       <xsl:variable name="v-abstract" as="xs:integer" visibility="public" select="93"/>
       
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/decl/override/override-v-004.xsl	Thu Jul 09 23:10:39 2015 +0100
@@ -0,0 +1,36 @@
+<xsl:package 
+  name="http://www.w3.org/xslt30tests/override-201"
+  package-version="1.0.1"
+  version="3.0"
+  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+  xmlns:xs="http://www.w3.org/2001/XMLSchema"
+  exclude-result-prefixes="xs">
+  
+  <!-- Test that global variables referenced in a match pattern can be overridden -->
+  
+  <xsl:use-package
+    name="http://www.w3.org/xslt30tests/override-base-201"
+    package-version="1.0.0">
+  
+    <xsl:override>
+  
+      <xsl:variable name="v-public" as="xs:integer" visibility="public" select="13"/>
+    
+      <xsl:variable name="v-abstract" as="xs:integer" visibility="public" select="93"/>
+      
+    </xsl:override>  
+    
+  </xsl:use-package>
+  
+  
+   
+    <xsl:template name="main">
+      <xsl:variable name="doc"><a><b/></a></xsl:variable>
+      <xsl:call-template name="go">
+        <xsl:with-param name="node" select="$doc//b"/>
+      </xsl:call-template>
+    </xsl:template>
+    
+ 
+  
+</xsl:package>   
\ No newline at end of file