2013-05-29 3 views
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> 
+0

문제를 재현 할 수 있도록 최소한이지만 완전한 샘플을 보여줄 것을 고려하십시오. 그 스 니펫으로 도울 까봐 두려운가? 그러면 함수 코드는 어떻게 보이나요? 함수가 호출되지 않았다는 것을 어떻게 알 수 있습니까? 변수의 값은 false입니까? 'bannerList' 변수는 true 또는 false가 아닌'content' 요소의 순서 여야합니다. –

+0

감사합니다. 내 문제는 내 함수가 부울 값이 아니라 문자열 'false'를 반환한다는 것입니다. – pethel

답변

1

사용 xsl:sequence하지 xsl:value-of는 데이터의 값이 표현이 입력 돌아갑니다. 그래서 당신은 <xsl:function name="pf:foo" as="xs:boolean">..</xsl:function>하여 함수의 반환 유형을 정의하는 경우 또한 당신이 더 이상 진단을받을 수 있습니다

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

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

를 교체합니다.