0

現在、XML からのフレームの総数を処理しています。私がやろうとしているのは、これを一定の時間で変換することです。fps が 30 であることはわかっています。フレームの総数を正しく計算し、これを秒に変換しました。私が今やろうとしているのは、この合計秒数を hh:mm:ss 形式で変更することです。

これが私のコードにあるものです:

<!-- call in template time-calc and then divid by 30fps to calulate total seconds of time-->
<xsl:variable name="TotalDurationShow"><xsl:call-template name="time-calculation"></xsl:call-template></xsl:variable>
<xsl:variable name="TotalSeconds" select="$TotalDurationShow div 30"/> 


<!-- Time-in-seconds to time in hh:mm:ss.000 form-->
<xsl:template name="secondsToTime">
    <xsl:param name="seconds" />
    <xsl:variable name="partHours"   select="floor($seconds div 60 div 60)" />
    <xsl:variable name="partMinutes" select="floor(($seconds - ($partHours * 60 * 60)) div 60)" />
    <xsl:variable name="partSeconds" select="$seconds - ($partHours * 60 * 60) - ($partMinutes * 60)" />
    <xsl:value-of select="concat(substring('0', 1, 2 - string-length(string( $partHours ))), $partHours)" /><xsl:text>:</xsl:text>
    <xsl:value-of select="concat(substring('0', 1, 2 - string-length(string( $partMinutes ))), $partMinutes)" /><xsl:text>:</xsl:text>
    <xsl:value-of select="concat(substring('0', 1, 2 - string-length(string( $partSeconds ))), $partSeconds)" />
</xsl:template>


<!-- test to make sure this is a number value in for total seconds
    call in template secondstotime on totalseconds variable to convert to time code formate hh:mm:ss-->
<xsl:if test="$TotalSeconds != 0 and string(number($TotalSeconds)) != 'NaN'">
    <xsl:variable name="TimeFrame"><xsl:call-template name="secondsToTime"><xsl:with-param name="seconds" select="$TotalSeconds" /></xsl:call-template></xsl:variable>
</xsl:if>

xsl:if をスプレッド シートの子にすることはできないというエラー メッセージが表示されます。if のテストを削除すると、param seconds が定義されていないというエラー メッセージが表示されます。変数 totalseconds でテンプレート secondstotime を呼び出すときに、何か間違ったことをしていますか?

4

1 に答える 1

1

計算した合計秒数を変換する方法 (この例では値は 2670 です)、それを hh:mm:ss を表示する出力に入れる方法

与えられた:

<xsl:variable name="TotalSeconds" select="2670"/>

あなたが使用することができます:

<xsl:variable name="h" select="floor($TotalSeconds div 3600)"/>
<xsl:variable name="m" select="floor($TotalSeconds div 60) mod 60"/>
<xsl:variable name="s" select="$TotalSeconds mod 60"/>

<xsl:value-of select="concat(format-number($h, '00'), format-number($m, ':00'), format-number($s, ':00'))" />

戻る:

00:44:30
于 2016-05-31T14:28:33.620 に答える