New test for static variable evaluating to a function
authorMichael Kay <mike@saxonica.com>
Wed, 25 Apr 2018 10:00:47 +0100
changeset 1842 30689b11f4c0
parent 1841 7b1b1f77a2d8
child 1843 097e32090c7b
New test for static variable evaluating to a function
tests/expr/higher-order-functions/_higher-order-functions-test-set.xml
tests/expr/higher-order-functions/higher-order-functions-074.xsl
--- a/tests/expr/higher-order-functions/_higher-order-functions-test-set.xml	Wed Apr 25 09:59:32 2018 +0100
+++ b/tests/expr/higher-order-functions/_higher-order-functions-test-set.xml	Wed Apr 25 10:00:47 2018 +0100
@@ -953,6 +953,19 @@
          <assert>/out = '10 x 2017'</assert>
       </result>
    </test-case>
+   
+   <test-case name="higher-order-functions-074">
+      <description>
+         Use higher order functions in a static variable initializer
+      </description>
+      <created by="Michael Kay" on="2018-04-24"/>
+      <test>
+         <stylesheet file="higher-order-functions-074.xsl"/>
+      </test>
+      <result>
+         <assert>/out = '18 iv 1924'</assert>
+      </result>
+   </test-case>
 </test-set>
 
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/expr/higher-order-functions/higher-order-functions-074.xsl	Wed Apr 25 10:00:47 2018 +0100
@@ -0,0 +1,15 @@
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+  xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:map="http://www.w3.org/2005/xpath-functions/map"
+  xmlns:f="http://local-functions/"
+  version="3.0" exclude-result-prefixes="xs map f">
+
+  <xsl:variable name="f" as="function(*)" static="no" select="function($in){xs:date(substring($in, 7, 4) || '-' || substring($in, 1, 2) || '-' ||substring($in, 4, 2))}"/>
+  
+  <xsl:param name="g" as="xs:date" select="$f('04-18-1924')"/>
+
+  <xsl:template name="xsl:initial-template">
+    <out><xsl:value-of select="format-date($g, '[D] [Mi] [Y0001]')"/></out>
+  </xsl:template>
+  
+
+</xsl:stylesheet>