2017-10-21 5 views
0

毎日の合計金額を表示したいと思います。私は以下のコードで試しました。 functx:翌日関数は、日付を設定するために使用されます。
入力
開始日= "2017年4月12日"xslt日付関連機能

NoDays = 6

価格= 15540

しかし、私は以下のような結果を示したいと思います。日付フィールドの値を設定する他の関数がありますか?

Current output: 


        <Night> 
         <Price Amount="2590" NightDate="2017-12-05" /> 
         <Price Amount="2590" NightDate="2017-12-06" /> 
         <Price Amount="2590" NightDate="2017-12-07" /> 
         <Price Amount="2590" NightDate="2017-12-08" /> 
         <Price Amount="2590" NightDate="2017-12-09" /> 
         <Price Amount="2590" NightDate="2017-12-10" /> 
        </Night> 




Expected Output: 

        <Night> 
         <Price Amount="2590" NightDate="2017-12-04" /> 
         <Price Amount="2590" NightDate="2017-12-05" /> 
         <Price Amount="2590" NightDate="2017-12-06" /> 
         <Price Amount="2590" NightDate="2017-12-07" /> 
         <Price Amount="2590" NightDate="2017-12-08" /> 
         <Price Amount="2590" NightDate="2017-12-09" /> 
        </Night> 



Currently used Logic: 

<Night>                         
    <xsl:for-each select="1 to $NoDays"> 

     <Price>                             

      <xsl:attribute name="Amount"> 

       <xsl:value-of select="$Price div $NoDays"/> 

     </xsl:attribute> 

      <xsl:attribute name="NightDate"> 

      <xsl:value-of select="functx:next- 
        day(xs:date($StartDate),position())"/> 

     </xsl:attribute> 

    </Price> 

</xsl:for-each> 

+1

質問を正しくフォーマットしてください。 – Tomalak

答えて

0

私はあなたが単にあなたが整数で時間を掛けて、日付に追加できることを悪用し

<xsl:variable name="NoDays" select="6"/> 
    <xsl:variable name="Price" select="15540"/> 
    <xsl:variable name="StartDate">04-12-2017</xsl:variable> 
    <xsl:variable name="date" as="xs:date" 
        select="xs:date(replace($StartDate, 
              '([0-9]{2})-([0-9]{2})-([0-9]{4})', 
              '$3-$2-$1'))"/> 
    <xsl:for-each select="0 to $NoDays - 1"> 
     <Price Amount="{$Price div $NoDays}" 
       NightDate="{$date + xs:dayTimeDuration('P1D') * .}"/> 
    </xsl:for-each> 

をしたいと思います。

オンラインサンプルhttp://xsltransform.net/bEzjRKT

+0

優れた解決策は、質問に値する処方よりも優れています。 –