Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/xslt/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Xslt 用于过滤的调用函数_Xslt_Xslt 2.0 - Fatal编程技术网

Xslt 用于过滤的调用函数

Xslt 用于过滤的调用函数,xslt,xslt-2.0,Xslt,Xslt 2.0,此函数“karusell:isCurrentDateTimeBetweenDates”从未被调用。为什么我不能使用它进行过滤?如果我单独调用一个函数并将其存储在一个变量中,它就会工作。变量的值为false <xsl:variable name="bannerList" select="verticaldata/contents/content[ karusell:isCurrentDateTimeBetweenDates( 'Thursday', '01' , 'Friday', '0

此函数“karusell:isCurrentDateTimeBetweenDates”从未被调用。为什么我不能使用它进行过滤?如果我单独调用一个函数并将其存储在一个变量中,它就会工作。变量的值为false

 <xsl:variable name="bannerList" select="verticaldata/contents/content[ karusell:isCurrentDateTimeBetweenDates( 'Thursday', '01' ,  'Friday', '03') ][position() &lt;= 5]" /> 

编辑: 如何返回字符串

过滤

功能

<xsl:function name="karusell:isCurrentDateTimeBetweenDates">    
    <xsl:param name="startDay"/>
    <xsl:param name="startHour" />
    <xsl:param name="endDay"/>
    <xsl:param name="endHour" />
    <xsl:variable name="currentDateTime" select="current-dateTime() " />


    <xsl:variable name="todayIndex" select="karusell:getDayIndex(format-dateTime($currentDateTime , '[F]'))" />
    <xsl:variable name="startDayIndex" select="karusell:getDayIndex($startDay)" />
    <xsl:variable name="endDayIndex" select="karusell:getDayIndex($endDay)" />

    <xsl:variable name="startDate" select= "$currentDateTime - ( $todayIndex - $startDayIndex )*xs:dayTimeDuration('P1D')"/>
    <xsl:variable name="endDate" select= "$currentDateTime + ( $endDayIndex - $todayIndex )*xs:dayTimeDuration('P1D')"/>


    <xsl:variable name="startDateTime" select="format-dateTime($startDate, concat('[Y0001]-[M01]-[D01]T', $startHour ,':00:00')) cast as xs:dateTime"/>  
    <xsl:variable name="endDateTime" select="format-dateTime($endDate, concat('[Y0001]-[M01]-[D01]T', $endHour ,':00:00')) cast as xs:dateTime"/>  

    <xsl:value-of select="$currentDateTime &gt;= $startDateTime and $currentDateTime &lt; $endDateTime" />
</xsl:function>

使用
xsl:sequence
,而不是
xsl:value of
返回表达式的数据类型值。因此,替换

<xsl:value-of select="$currentDateTime &gt;= $startDateTime and $currentDateTime &lt; $endDateTime" />



此外,如果您使用
定义函数的返回类型,您可以获得更好的错误诊断。

请考虑向我们显示最小但完整的示例,以便我们重现问题。恐怕仅仅凭这一段就很难帮助你了?那么函数代码看起来如何?您如何注意到函数没有被调用?哪个变量的值为false?
bannerList
变量应该是一系列
content
元素,而不是true或false。谢谢。我的问题是,我的函数返回字符串'false'而不是布尔值。
<xsl:sequence select="$currentDateTime &gt;= $startDateTime and $currentDateTime &lt; $endDateTime" />