在 XSLT 中将丢帧数转换为秒数

Converting number of drop frames to seconds in XSLT

我目前正在处理 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 不能是传播 sheet 的子项。当我删除 if 的测试时,我收到一条错误消息,指出参数秒未定义。在我的变量 totalseconds 上调用模板 secondstotime 时,我做错了什么吗?

how to convert the total number of seconds which I have calculated (This example the value is 2670) and put that into an output that displays 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'))" />

到return:

00:44:30