在xslt 1.0中有以下更优雅的解决方案吗?据我所知,xslt 2.0内置了函数.
我在十进制小时内取一个数字,需要将其表示为HH:MM:SS.目前我有以下功能正常.
<xsl:variable name="decimal_hours" select="pre_lab_cost div pre_labour_rate"/>
<xsl:variable name="decimal_minutes" select="number(concat('0.',substring-after($decimal_hours, '.')))*60"/>
<xsl:variable name="decimal_seconds" select="number(concat('0.',substring-after($decimal_minutes, '.')))*60"/>
<xsl:value-of select="concat(format-number(floor($decimal_hours), '00'),
':',
format-number(floor($decimal_minutes), '00'),
':',
format-number(floor($decimal_seconds), '00')
)"/>
Run Code Online (Sandbox Code Playgroud)
这个怎么样 ...
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text"/>
<xsl:variable name="decimal_hours" select="3.14"/>
<xsl:template match="/">
<xsl:value-of select="concat(
format-number(floor($decimal_hours ), '00:'),
format-number(floor($decimal_hours * 60 mod 60), '00:'),
format-number(floor($decimal_hours * 360 mod 360), '00'))"/>
</xsl:template>
</xsl:stylesheet>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1975 次 |
| 最近记录: |