0

この関数「karusell:isCurrentDateTimeBetweenDates」は呼び出されません。フィルタリングに使用できないのはなぜですか? i を単独で呼び出して変数に格納すると、機能します。変数の値は 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>
4

1 に答える 1

1

,を使用して、式が持つデータ型の値を返しxsl:sequenceません。xsl:value-ofだから交換

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

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

さらに、関数の戻り値の型を で定義すると、より適切なエラー診断を得ることができます<xsl:function name="pf:foo" as="xs:boolean">..</xsl:function>

于 2013-05-29T10:10:06.647 に答える